Example (standard-style syntax). Verify supported keywords in your database.
CREATE TABLE projects (id INTEGER PRIMARY KEY, name VARCHAR(120) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP);Create a table with columns and constraints.
CREATE TABLE table_name (column_name data_type [constraint], ...);Example (standard-style syntax). Verify supported keywords in your database.
CREATE TABLE projects (id INTEGER PRIMARY KEY, name VARCHAR(120) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP);SQLite-oriented variant; dialect behaviour may differ.
CREATE TABLE projects (id INTEGER PRIMARY KEY, name TEXT NOT NULL, created_at TEXT DEFAULT CURRENT_TIMESTAMP);| Option / clause | Description |
|---|---|
column_name data_type | Define each column and its database type. |
NOT NULL / DEFAULT | Require a value or provide a default for omitted values. |
PRIMARY KEY / FOREIGN KEY | Define row identity and references to another table. |
UNIQUE / CHECK | Enforce uniqueness or a Boolean condition. |
IF NOT EXISTS | Avoid an error if the table already exists where supported. |
Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.