diff --git a/_data/sidebar_doc.yml b/_data/sidebar_doc.yml index a0707d13b73..65fd8a400ba 100644 --- a/_data/sidebar_doc.yml +++ b/_data/sidebar_doc.yml @@ -57,198 +57,62 @@ entries: url: /install-client-drivers.html thirdlevel: - - title: SQL Statements + - title: Program SQL queries thirdlevelitems: - - title: Overview - url: /sql-statements.html - - - title: ADD COLUMN - url: /add-column.html - - - title: ADD CONSTRAINT - url: /add-constraint.html - - - title: ALTER COLUMN - url: /alter-column.html - - - title: ALTER TABLE - url: /alter-table.html - - - title: ALTER VIEW - url: /alter-view.html - - - title: BEGIN - url: /begin-transaction.html - - - title: COMMIT - url: /commit-transaction.html - - - title: CREATE DATABASE - url: /create-database.html - - - title: CREATE INDEX - url: /create-index.html - - - title: CREATE TABLE - url: /create-table.html - - - title: CREATE TABLE AS - url: /create-table-as.html - - - title: CREATE USER - url: /create-user.html - - - title: CREATE VIEW - url: /create-view.html - - - title: DELETE - url: /delete.html - - - title: DROP COLUMN - url: /drop-column.html - - - title: DROP CONSTRAINT - url: /drop-constraint.html - - - title: DROP DATABASE - url: /drop-database.html - - - title: DROP INDEX - url: /drop-index.html - - - title: DROP TABLE - url: /drop-table.html - - - title: DROP VIEW - url: /drop-view.html - - - title: EXPLAIN - url: /explain.html - - - title: GRANT - url: /grant.html - - - title: INSERT - url: /insert.html - - - title: RENAME COLUMN - url: /rename-column.html - - - title: RENAME DATABASE - url: /rename-database.html - - - title: RENAME INDEX - url: /rename-index.html - - - title: RENAME TABLE - url: /rename-table.html - - - title: RELEASE SAVEPOINT - url: /release-savepoint.html - - - title: REVOKE - url: /revoke.html - - - title: ROLLBACK - url: /rollback-transaction.html - - - title: SAVEPOINT - url: /savepoint.html - - - title: SELECT - url: /select.html - - - title: SET DATABASE - url: /set-database.html - - - title: SET TIME ZONE - url: /set-time-zone.html - - - title: SET TRANSACTION - url: /set-transaction.html - - - title: SHOW ALL - url: /show-all.html + - title: Query and Update Statements + url: /sql-statements.html#query-and-update-statements - - title: SHOW COLUMNS - url: /show-columns.html + - title: Table Expressions + url: /table-expressions.html - - title: SHOW CONSTRAINTS - url: /show-constraints.html + - title: Constant Values + url: /sql-constants.html - - title: SHOW CREATE TABLE - url: /show-create-table.html + - title: Value Expressions + url: /sql-expressions.html - - title: SHOW CREATE VIEW - url: /show-create-view.html + - title: Built-in Functions and Operators + url: /functions-and-operators.html - - title: SHOW DATABASE - url: /show-database.html - - - title: SHOW DATABASES - url: /show-databases.html - - - title: SHOW GRANTS - url: /show-grants.html - - - title: SHOW INDEX - url: /show-index.html - - - title: SHOW TABLES - url: /show-tables.html - - - title: SHOW TIME ZONE - url: /show-time-zone.html - - - title: SHOW TRANSACTION - url: /show-transaction.html - - - title: SHOW USERS - url: /show-users.html - - - title: TRUNCATE - url: /truncate.html + - title: Data Types + url: /data-types.html - - title: UPDATE - url: /update.html + - title: Information Schema + url: /information-schema.html - - title: UPSERT - url: /upsert.html + - title: Keywords & Identifiers + url: /keywords-and-identifiers.html - - title: SQL Grammar - url: /sql-grammar.html + - title: SQL Grammar + url: /sql-grammar.html - thirdlevel: - - title: Constraints + - title: Use Transactions thirdlevelitems: - title: Overview - url: /constraints.html - - - title: Check - url: /check.html + url: /transactions.html - - title: Default Value - url: /default-value.html + - title: Transaction Management Statements + url: /sql-statements.html#transaction-management-statements - - title: Foreign Keys - url: /foreign-key.html + - title: Automatic and Manual Retries + url: /transactions.html#transaction-retries - - title: Not Null - url: /not-null.html + - title: Priorities + url: /transactions.html#transaction-priorities - - title: Primary Key - url: /primary-key.html - - - title: Unique - url: /unique.html + - title: Isolation Levels + url: /transactions.html#isolation-levels - title: Data Definition thirdlevelitems: - - title: Keywords & Identifiers - url: /keywords-and-identifiers.html + - title: Data Definition Statements + url: /sql-statements.html#data-definition-statements + + - title: Column Constraints + url: /constraints.html - title: Indexes url: /indexes.html @@ -265,56 +129,20 @@ entries: - title: NULL Handling url: /null-handling.html - - title: Data Types + - title: Information Schema + url: /information-schema.html + + - title: Privileges thirdlevelitems: - title: Overview - url: /data-types.html - - - title: INT - url: /int.html - - - title: SERIAL - url: /serial.html - - - title: DECIMAL - url: /decimal.html - - - title: FLOAT - url: /float.html - - - title: BOOL - url: /bool.html - - - title: DATE - url: /date.html + url: /privileges.html - - title: TIMESTAMP - url: /timestamp.html + - title: Privilege Management Statements + url: /sql-statements.html#privilege-management-statements - - title: INTERVAL - url: /interval.html - - - title: STRING - url: /string.html - - - title: COLLATE - url: /collate.html - - - title: BYTES - url: /bytes.html - - - title: Privileges - url: /privileges.html - - - title: Functions and Operators - url: /functions-and-operators.html - - - title: Transactions - url: /transactions.html - - - title: Information Schema - url: /information-schema.html + - title: Create and Manage Users + url: /create-and-manage-users.html - title: Deploy items: @@ -349,7 +177,7 @@ entries: - title: Overview url: /orchestration.html - + - title: Kubernetes url: /orchestrate-cockroachdb-with-kubernetes.html @@ -428,7 +256,7 @@ entries: - title: SQL url: /sql.html - + - title: Distributed Transactions url: /distributed-transactions.html diff --git a/sql-statements.md b/sql-statements.md index d17b9d4d6a7..30c02c7a83e 100644 --- a/sql-statements.md +++ b/sql-statements.md @@ -6,55 +6,81 @@ toc: false CockroachDB supports the following SQL statements. Click a statement for more details. -Statement | Usage +## Query and Update Statements + +Statement | Usage +----------|------------ +[`CREATE TABLE AS`](create-table-as.html) | Create a new table in a database using the results from a `SELECT` statement. +[`DELETE`](delete.html) | Delete specific rows from a table. +[`EXPLAIN`](explain.html) | View debugging and analysis details for a `SELECT`, `INSERT`, `UPDATE`, or `DELETE` statement. +[`INSERT`](insert.html) | Insert rows into a table. +[`SELECT`](select.html) | Select rows from a table. +[`TRUNCATE`](truncate.html) | Deletes all rows from specified tables. +[`UPDATE`](update.html) | Update rows in a table. +[`UPSERT`](upsert.html) | Insert rows that do not violate uniqueness constraints; update rows that do. + +## Data Definition Statements + +Statement | Usage ----------|------------ [`ADD COLUMN`](add-column.html) | Add columns to a table. [`ADD CONSTRAINT`](add-constraint.html) | Add a constraint to a column. [`ALTER COLUMN`](alter-column.html) | Change a column's [Default constraint](default-value.html) or drop the [Not Null constraint](not-null.html). [`ALTER TABLE`](alter-table.html) | Apply a schema change to a table. [`ALTER VIEW`](alter-view.html) | Rename a view. -[`BEGIN`](begin-transaction.html)| Initiate a [transaction](transactions.html). -[`COMMIT`](commit-transaction.html) | Commit the current [transaction](transactions.html). [`CREATE DATABASE`](create-database.html) | Create a new database. [`CREATE INDEX`](create-index.html) | Create an index for a table. -[`CREATE TABLE`](create-table.html) | Create a new table in a database. +[`CREATE TABLE`](create-table.html) | Create a new table in a database. [`CREATE TABLE AS`](create-table-as.html) | Create a new table in a database using the results from a `SELECT` statement. -[`CREATE USER`](create-user.html) | Creates a SQL user, which lets you control [privileges](privileges.html) on your databases and tables. [`CREATE VIEW`](create-view.html) | Create a new [view](views.html) in a database. -[`DELETE`](delete.html) | Delete specific rows from a table. [`DROP COLUMN`](drop-column.html) | Remove columns from a table. [`DROP CONSTRAINT`](drop-constraint.html) | Remove constraints from a column. [`DROP DATABASE`](drop-database.html) | Remove a database and all its objects. [`DROP INDEX`](drop-index.html) | Remove an index for a table. [`DROP TABLE`](drop-table.html) | Remove a table. [`DROP VIEW`](drop-view.html)| Remove a view. -[`EXPLAIN`](explain.html) | View debugging and analysis details for a `SELECT`, `INSERT`, `UPDATE`, or `DELETE` statement. -[`GRANT`](grant.html) | Grant privileges to users. -[`INSERT`](insert.html) | Insert rows into a table. [`RENAME COLUMN`](rename-column.html) | Rename a column in a table. [`RENAME DATABASE`](rename-database.html) | Rename a database. [`RENAME INDEX`](rename-index.html) | Rename an index for a table. [`RENAME TABLE`](rename-table.html) | Rename a table or move a table between databases. -[`RELEASE SAVEPOINT`](release-savepoint.html) | When using the CockroachDB-provided function for client-side [transaction retries](transactions.html#transaction-retries), commit the transaction's changes once there are no retryable errors. -[`REVOKE`](revoke.html) | Revoke privileges from users. -[`ROLLBACK`](rollback-transaction.html) | Discard all updates made by the current [transaction](transactions.html) or, when using the CockroachDB-provided function for client-side [transaction retries](transactions.html#transaction-retries), rollback to the `cockroach_restart` savepoint and retry the transaction. -[`SELECT`](select.html) | Select rows from a table. -[`SET DATABASE`](set-database.html) | Set the default database for the session. -[`SET TIME ZONE`](set-time-zone.html) | Set the default time zone for the session. -[`SET TRANSACTION`](set-transaction.html) | Set the isolation level or priority for the session or for an individual [transaction](transactions.html). -[`SHOW ALL`](show-all.html) | List all current run-time settings. [`SHOW COLUMNS`](show-columns.html) | View details about columns in a table. [`SHOW CONSTRAINTS`](show-constraints.html) | List constraints on a table. [`SHOW CREATE TABLE`](show-create-table.html) | View the `CREATE TABLE` statement that would create a carbon copy of the specified table. [`SHOW CREATE VIEW`](show-create-view.html) | View the `CREATE VIEW` statement that would create a carbon copy of the specified view. -[`SHOW DATABASE`](show-database.html) | List the default database for the session. [`SHOW DATABASES`](show-databases.html) | List databases in the cluster. -[`SHOW GRANTS`](show-grants.html) | View privileges granted to users. -[`SHOW INDEX`](show-index.html) | View index information for a table. +[`SHOW INDEX`](show-index.html) | View index information for a table. [`SHOW TABLES`](show-tables.html) | List tables in a database. -[`SHOW TIME ZONE`](show-time-zone.html) | View the default time zone for the session. + +## Transaction Management Statements + +Statement | Usage +----------|------------ +[`BEGIN`](begin-transaction.html)| Initiate a [transaction](transactions.html). +[`COMMIT`](commit-transaction.html) | Commit the current [transaction](transactions.html). +[`RELEASE SAVEPOINT`](release-savepoint.html) | When using the CockroachDB-provided function for client-side [transaction retries](transactions.html#transaction-retries), commit the transaction's changes once there are no retryable errors. +[`ROLLBACK`](rollback-transaction.html) | Discard all updates made by the current [transaction](transactions.html) or, when using the CockroachDB-provided function for client-side [transaction retries](transactions.html#transaction-retries), rollback to the `cockroach_restart` savepoint and retry the transaction. +[`SAVEPOINT`](savepoint.html) | When using the CockroachDB-provided function for client-side [transaction retries](transactions.html#transaction-retries), start a retryable transaction. +[`SET TRANSACTION`](set-transaction.html) | Set the isolation level or priority for the session or for an individual [transaction](transactions.html). [`SHOW TRANSACTION`](show-transaction.html) | View the isolation level or priority for the session or for an individual [transaction](transactions.html). + +## Privilege Management Statements + +Statement | Usage +----------|------------ +[`CREATE USER`](create-user.html) | Creates a SQL user, which lets you control [privileges](privileges.html) on your databases and tables. +[`GRANT`](grant.html) | Grant privileges to users. +[`REVOKE`](revoke.html) | Revoke privileges from users. +[`SHOW GRANTS`](show-grants.html) | View privileges granted to users. [`SHOW USERS`](show-users.html) | Lists the users for all databases. -[`TRUNCATE`](truncate.html) | Deletes all rows from specified tables. -[`UPDATE`](update.html) | Update rows in a table. -[`UPSERT`](upsert.html) | Insert rows that do not violate uniqueness constraints; update rows that do. + +## Session Management Statements + +Statement | Usage +----------|------------ +[`SET DATABASE`](set-database.html) | Set the default database for the session. +[`SET TIME ZONE`](set-time-zone.html) | Set the default time zone for the session. +[`SET TRANSACTION`](set-transaction.html) | Set the isolation level or priority for the session or for an individual [transaction](transactions.html). +[`SHOW ALL`](show-all.html) | List all current run-time settings. +[`SHOW DATABASE`](show-database.html) | List the default database for the session. +[`SHOW TIME ZONE`](show-time-zone.html) | View the default time zone for the session. +[`SHOW TRANSACTION`](show-transaction.html) | View the isolation level or priority for the session or for an individual [transaction](transactions.html).