如何为oracle中的表增加像sqlserver一样的自动列

发表于:2007-05-25来源:作者:点击数: 标签:oracleSQLServer何为增加中的

  conn scott/tiger@powermis
  
  drop table foo;
  
  create table foo(
   id number primary key,
   data varchar2(100));
  
  create sequence foo_seq;
  
  create or replace trigger bifer_foo_id_pk
   before insert
    on foo
    for each row
  begin
   select foo_seq.nextval into :new.id from dual;
  end;
  /
  
  insert into foo(data)
   values('Chirstopher');
  
  insert into foo(id,data)
   values(5,'Sean');
  
  select * from foo;

原文转自:http://www.ltesting.net