oracle建表並加自增序列

2021-06-07 23:04:31 字數 866 閱讀 5199

建表

create table bi_mlk_searchkeyword(

id number(30) primary key,

keyword varchar2(30),

times number(30) not null,

inputdate date,

pinyin varchar2(50),

firstpinyin varchar2(30),

english varchar2(50)

建序列drop sequence dectuser_tb_seq;

create sequence dectuser_tb_seq minvalue 1 maxvalue 99999999

increment by 1

start with 1;   /*步長為1*/

給表新增自增序列              

create or replace trigger dectuser_tb_tri

before insert on bi_mlk_searchkeyword     /*觸發條件:當向表dectuser執行插入操作時觸發此觸發器*/

for each row                       /*對每一行都檢測是否觸發*/

begin                                  /*觸發器開始*/

select dectuser_tb_seq.nextval into :new.id from dual;   /*觸發器主題內容,即觸發後執行的動作,在此是取得序列dectuser_tb_seq的下乙個值插入到表dectuser中的userid欄位中*/

end;  

commit;

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 test id number 4 not null primary key,name varchar2 25 序列 create sequence test sequence increment by 1 每次增加幾個 start wi...

oracle建表設定主鍵自增

首先建立一張表 create table member memberid number primary key,membermail varchar2 20 not null,membername varchar2 20 not null,memberpassword varchar2 20 然後,...