Lenmore Blog -- 我的记事本、备忘录

如何在仅有一个自增字段的表中插入数据

written on Friday, December 18, 2009

MSSQL Server:

CREATE TABLE dbo.t1(id INT IDENTITY(1,1))
INSERT INTO dbo.t1 DEFAULT VALUES

MySQL:

CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY);
INSERT INTO t1(id) VALUES(DEFAULT);

PostgreSQL:

CREATE TABLE t1 (id SERIAL);
INSERT INTO t1(id) VALUES(DEFAULT);
OR
INSERT INTO t1 DEFAULT VALUES;

This entry was tagged database