DB
CREATE TABLE T
(
id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH
);
Oracle(需要創建一個SEQUENCE和一個TRIGGER)
CREATE TABLE T
(
id NUMBER(
);
CREATE SEQUENCE T
CREATE OR REPLACE TRIGGER INSERT_T
BEFORE INSERT ON T
REFERENCING NEW AS new OLD AS old
FOR EACH ROW
BEGIN
SELECT T
END;
MySQL
CREATE TABLE T
(
id INT NOT NULL AUTO_INCREMENT
);
PostgreSQL
CREATE TABLE T
(
id SERIAL NOT NULL
);
SQL Server
CREATE TABLE T
(
id INT NOT NULL IDENTITY
);
Sybase
CREATE TABLE T
(
id INT NOT NULL IDENTITY
);
From:http://tw.wingwit.com/Article/program/Oracle/201311/19047.html