需要修改的地方都已經加粗了
一、建立表
create table ORGUSER
(
id NUMBER not null,
name VARCHAR2(255),
sex NUMBER(1),
age NUMBER(3)
)
二、建立主鍵
alter table ORGUSER
add constraint 主鍵 primary key (ID)
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
三、建立序列
CREATE SEQUENCE ORGUSER_ID_S; – ORGUSER_ID_S是序列名稱
四、建立觸發器
create or replace trigger ORGUSER_ID_T
before insert
on ORGUSER
for each row
declare
– local variables here
begin
SELECT ORGUSER_ID_S.nextval INTO :new.id FROM dual;
END ORGUSER_ID_T;