关于Oracle创建表,字段自动增长
1.建立测试数据表CREATE TABLE TEST
(
ID NUMBER,
NAME VARCHAR2(20),
PRIMARY KEY(ID)
);
2.创建序列CREATE SEQUENCE SEQ_TEST;
3.创建触发器CREATE OR REPLACE TRIGGER AUTOINCREMENT
BEFORE INSERT ON TEST
FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT SEQ_TEST.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
/
4.插入数据INSERT INTO TEST(NAME) VALUES('NAME1');
5.查看插入结果SELECT * FROM TEST;