首页 > 数据库 > SQL Server > 正文

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

2024-08-31 00:52:04
字体:
来源:转载
供稿:网友

  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;

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表