關(guān)鍵字: oracle中創(chuàng)建表,創(chuàng)建序列,創(chuàng)建自增字段,添加注釋, 添加記錄,添加觸發(fā)器,提交
// 創(chuàng)建一個序列
CREATE SEQUENCE Car_GUID increment by 1;
// 創(chuàng)建一個表
CREATE TABLE Car
(
GUID NUMBER NOT NULL PRIMARY KEY,
PhoneId Char(11) NOT NULL,
UserName VarChar(20) NOT NULL
);
// 添加注釋
comment on table car is '定位信息用戶表';
Comment on column car.guid is '自增字段';
Comment on column Car.PhoneId is '電話唯一標(biāo)識';
Comment on column Car.UserName is '用戶名稱';
// 添加一條記錄
INSERT INTO Car(GUID, PhoneId, UserName) Values(CAR_GUID.nextval, '13589256783', '張三');
// 提交
commit;
// 觸發(fā)器
create or replace trigger Trigger_Car_GUID_Insert
before insert on Car
for each row
begin
select CARGUIDSEQ.nextval into :new.GUID from sys.dual;
end;