我有一些表,这些表是执行某些动态sql语句搞出来的。
比如:create table table1 as select * from xs where name='zhangsan'以后我需要向这个表里插入数据
insert into table1 select * from xs where name="lisi"问题是我在powerbuilder里构造、执行这样的sql语句没有问题,但我还要通过datawindow来更新这张表。按照我目前对pb的理解,这样的表(table1)一定要有主键才行,而动态生成的表是不能确定哪些字段是主键。本段是介绍背景,oracle高人可以不比理睬pb里面的冬冬。核心问题,我觉得是:动态生成的表怎样获得主键,alter sql我会写的,用什么做主键呢?如果我用序列做主键的话,那么估计create table,insert into这样的语句,怎么利用序列呢?
有没有更好的方法?我要主键!

解决方案 »

  1.   

    You can generate a unique rank for each row and use it as the primary key, but it is better to obtain the original database structure and set the primary key to an existing column.
      

  2.   

    You can generate a unique rank for each row and use it as the primary key..
    How ??
    请大侠详细指定。
      

  3.   

    You can generate a unique rank for each row and use it as the primary key..
    我觉得应该是:
    新增加一列,并(利用sequence或者其他方式)生成唯一的值,把这一列作为主键
      

  4.   

    但是我知道在oracle中每個表都是有Rowid的
    這個列的值是唯一的。
    但是PB裏是要求數據唯一就可以還是,一定要有實體的主健存在呢?
    要看看PB裏是怎麽要求的?
      

  5.   

    rowid,rownum,pb的数据窗口不认识的,