Oacle 자체 가중 id 구현

1173 단어 Oacle
--oracle     id
--    T_StudentInfo 

create table T_StudentInfo
(
       "id" integer not null primary key,
       xsName nvarchar2(120) not null,
       xsAge integer not null,
       Mobile varchar(12),
       Email varchar(50),
       Address nvarchar2(300) 
       
);

--      ,     SEQ_StudentInfo_Identity
--      (            SEQ  ,     。       。    T_    ,   _Identity  ,            Id       )
       create sequence SEQ_StudentInfo_Identity     
       increment by 1 --      。        1
       start with 1   -- 1    
       nomaxvalue      --      
       nocycle         --    ,   
       nocache;        --     
       
--            ,            

--               Trg_Studentinfo_Identity
--         Trg  _     ,            
create trigger Trg_Studentinfo_Identity before
insert on T_StudentInfo for each row when(new.id is null) 
begin
select id_sequence.nextval into:new.id from dual;
end;  

http://www.2cto.com/database/201305/214692.html

좋은 웹페이지 즐겨찾기