Tag archive
Commands grouped around the same concept, pattern, or recurring problem.
Extend a table's structure by adding a new column with `ALTER TABLE`.
Enforce referential integrity by linking a column to the primary key of another table so orphaned rows cannot be inserted.
Modify the data type, default value, or nullability of an existing column without recreating the table.
Save a `SELECT` statement as a named view so it can be queried like a table.
Define a new table with column names and data types using `CREATE TABLE`.
Materialize a query's output as a new table in one step using `CREATE TABLE AS SELECT` or `SELECT INTO`.
Build a table that exists only for the current session and is discarded automatically when the connection closes.
Permanently remove a table and all its data with `DROP TABLE`.
Create a unique index so the database rejects duplicate values in one or more columns.
Define a column default so inserts can omit routine values and still store a complete row.
Define an identity or auto-increment column so new rows receive numeric IDs without the insert supplying them.
Permanently delete a column and all its data from a table using ALTER TABLE.
Delete every row in a table quickly with TRUNCATE TABLE, which is faster than DELETE with no WHERE clause.
Drop an index that is no longer useful so writes no longer have to maintain it.
Change a column's name in place without dropping or recreating the table or its data.
Change a table name while keeping its existing rows and columns.
Create an index on one or more columns to make lookups and joins faster.
Define a column whose value is always derived from an expression over other columns — the database recomputes or stores it on every write so queries never need to repeat the formula.
Use a `CHECK` constraint to reject rows whose values fall outside an allowed rule.