oracle建表,建主鍵,自增
--建表
create table test(
id number(4) not null primary key,
name varchar2(25)
--序列
create sequence test_sequence
increment by 1--每次增加幾個
start with 1 --從1開始計數
minvalue 1
nomaxvalue --不設定最大值
nocycle --一直累加,不迴圈
nocache --不建緩衝區
--觸發器
create trigger test_tiger before
insert on test for each row when(new.id is null)
begin
select test_sequence.nextval into:new.id from dual;
end;
--測試
insert into test(name) values(『zhangsan『);
對已有的表中資料,對id進行自增設置
create sequence seq_a_id
minvalue 1
nomaxvalue
start with 1
increment by 1
nocache;
update sys_menu_dict set menu_id = seq_a_id.nextval
原文:
oracle建表設定主鍵自增
首先建立一張表 create table member memberid number primary key,membermail varchar2 20 not null,membername varchar2 20 not null,memberpassword varchar2 20 然後,...
oracle建表並主鍵自增
oracle建表,並設主鍵自增 建立使用者表 create table user info t id integer not null user id varchar 50 user name varchar 50 user password varchar 50 user varchar 20 u...
oracle建表設定主鍵自增
oracle建表設定主鍵自增 首先建立一張表 create table member memberid number primary key,membermail varchar2 20 not null,membername varchar2 20 not null,memberpassword ...