CREATE TABLE

A DDL command for defining a new table

CREATE TABLE is a DDL command for defining a new table.

CREATE TABLE has always been present in PostgreSQL.

Change history

Work-in-progress

Examples

Basic usage example for CREATE TABLE:

postgres=# CREATE TABLE foo (id INT NOT NULL PRIMARY KEY, val TEXT);
CREATE TABLE

postgres=# \d foo
                Table "public.foo"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 id     | integer |           | not null |
 val    | text    |           |          |
Indexes:
    "foo_pkey" PRIMARY KEY, btree (id)

Categories

DDL, SQL command

See also

ALTER TABLE, DROP TABLE, CREATE TABLE AS