sqlcmd.net validated sql reference

#schema

Commands grouped around the same concept, pattern, or recurring problem.

18 commands with this tag Browse related patterns quickly
beginner defining MySQL MariaDB SQL Server PostgreSQL SQLite

Add A Column To An Existing Table

Extend a table's structure by adding a new column with `ALTER TABLE`.

intermediate ddl MySQL MariaDB SQL Server PostgreSQL

Change a Column's Data Type With ALTER TABLE

Modify the data type, default value, or nullability of an existing column without recreating the table.

intermediate defining MySQL MariaDB SQL Server PostgreSQL SQLite

Create A Reusable Query With CREATE VIEW

Save a `SELECT` statement as a named view so it can be queried like a table.

beginner defining MySQL MariaDB SQL Server PostgreSQL SQLite

Create A Table

Define a new table with column names and data types using `CREATE TABLE`.

beginner defining MySQL MariaDB SQL Server PostgreSQL SQLite

Delete A Table

Permanently remove a table and all its data with `DROP TABLE`.

intermediate defining MySQL MariaDB SQL Server PostgreSQL SQLite

Enforce Uniqueness With CREATE UNIQUE INDEX

Create a unique index so the database rejects duplicate values in one or more columns.

beginner inserting MySQL MariaDB SQL Server PostgreSQL SQLite

Fill Omitted Columns With DEFAULT

Define a column default so inserts can omit routine values and still store a complete row.

intermediate defining MySQL MariaDB SQL Server PostgreSQL SQLite

Generate Row IDs Automatically

Define an identity or auto-increment column so new rows receive numeric IDs without the insert supplying them.

beginner metadata MySQL MariaDB SQL Server PostgreSQL SQLite

List Columns In A Table

Inspect a table definition to see its column names and data types.

beginner metadata MySQL MariaDB SQL Server PostgreSQL SQLite

List Tables

Inspect the current database or schema to see which tables exist.

intermediate defining MySQL MariaDB SQL Server PostgreSQL SQLite

Remove A Column From A Table With ALTER TABLE DROP COLUMN

Permanently delete a column and all its data from a table using ALTER TABLE.

intermediate defining MySQL MariaDB SQL Server PostgreSQL SQLite

Remove an Index With DROP INDEX

Drop an index that is no longer useful so writes no longer have to maintain it.

beginner ddl MySQL MariaDB SQL Server PostgreSQL SQLite

Rename a Column With ALTER TABLE

Change a column's name in place without dropping or recreating the table or its data.

intermediate defining MySQL MariaDB SQL Server PostgreSQL SQLite

Rename a Table

Change a table name while keeping its existing rows and columns.

advanced defining MySQL MariaDB SQL Server PostgreSQL SQLite

Speed Up Queries With CREATE INDEX

Create an index on one or more columns to make lookups and joins faster.

intermediate schema MySQL MariaDB SQL Server PostgreSQL SQLite

Store a Computed Value Automatically With Generated Columns

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.

intermediate defining MySQL MariaDB SQL Server PostgreSQL SQLite

Validate Column Values With CHECK

Use a `CHECK` constraint to reject rows whose values fall outside an allowed rule.

advanced metadata MySQL MariaDB SQL Server PostgreSQL SQLite

Why Structure Outlives Query Text

Schema and metadata choices tend to survive longer than any one statement, which is why naming and structure deserve more care than a temporary query draft.