CREATE SEQUENCE (ANSI)
CREATE SEQUENCE (ANSI) is a SQL statement in the DDL Statements category. ANSI SQL standard sequence object. Supported in PostgreSQL, Oracle, SQL Server (2012+), IBM DB2. The syntax is CREATE SEQUENCE seq_name START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 9999 CYCLE;. It returns sequence object. A typical example: CREATE SEQUENCE order_num_seq START WITH 10000 INCREMENT BY 1 CACHE 20; SELECT NEXT VALUE FOR order_num_seq; -- 10000 SELECT NEXT VALUE FOR order_num_seq; -- 10001 -- Use as DEFAULT: CREATE TABLE orders (id INT DEFAULT NEXT VALUE FOR order_num_seq, name TEXT); A close relative is CREATE TABLE, which creates a new table in the database with specified columns, data types, and constraints. A close relative is ALTER TABLE, which modifies an existing table: add/drop columns, modify data types, rename, add/drop constraints. A close relative is DROP TABLE, which permanently removes a table and all its data from the database. Cannot be undone.