Skip to content

Commit

Permalink
Update all SHOW statements
Browse files Browse the repository at this point in the history
Fixes #3467.
Fixes #3371.

This PR updates the primary places in the docs where we cover
SHOW statements. There may still be some out-dated examples,
but we can update those as we go.

This PR also combines SHOW CREATE TABLE, SHOW
CREATE VIEW, and SHOW CREATE SEQUENCE into a single SHOW
CREATE page, and removes the experimental status
from SHOW CONSTRAINTS.

EXPLAIN will be handled separately.
  • Loading branch information
jseldess committed Aug 8, 2018
1 parent bd8bf97 commit c262afa
Show file tree
Hide file tree
Showing 85 changed files with 1,295 additions and 1,419 deletions.
16 changes: 2 additions & 14 deletions _includes/sidebar-data-v2.1.json
Expand Up @@ -921,21 +921,9 @@
]
},
{
"title": "<code>SHOW CREATE SEQUENCE</code>",
"title": "<code>SHOW CREATE</code>",
"urls": [
"/${VERSION}/show-create-sequence.html"
]
},
{
"title": "<code>SHOW CREATE TABLE</code>",
"urls": [
"/${VERSION}/show-create-table.html"
]
},
{
"title": "<code>SHOW CREATE VIEW</code>",
"urls": [
"/${VERSION}/show-create-view.html"
"/${VERSION}/show-create.html"
]
},
{
Expand Down
16 changes: 16 additions & 0 deletions _includes/v2.1/sql/diagrams/show_create.html
@@ -0,0 +1,16 @@
<div><svg width="330" height="36">
<polygon points="9 17 1 13 1 21"></polygon>
<polygon points="17 17 9 13 9 21"></polygon>
<rect x="31" y="3" width="62" height="32" rx="10"></rect>
<rect x="29" y="1" width="62" height="32" class="terminal" rx="10"></rect>
<text class="terminal" x="39" y="21">SHOW</text>
<rect x="113" y="3" width="72" height="32" rx="10"></rect>
<rect x="111" y="1" width="72" height="32" class="terminal" rx="10"></rect>
<text class="terminal" x="121" y="21">CREATE</text>
<rect x="205" y="3" width="98" height="32"></rect>
<rect x="203" y="1" width="98" height="32" class="nonterminal"></rect>
<text class="nonterminal" x="213" y="21">object_name</text>
<path class="line" d="m17 17 h2 m0 0 h10 m62 0 h10 m0 0 h10 m72 0 h10 m0 0 h10 m98 0 h10 m3 0 h-3"></path>
<polygon points="321 17 329 13 329 21"></polygon>
<polygon points="321 17 313 13 313 21"></polygon>
</svg></div>
19 changes: 0 additions & 19 deletions _includes/v2.1/sql/diagrams/show_create_sequence.html

This file was deleted.

22 changes: 0 additions & 22 deletions _includes/v2.1/sql/diagrams/show_create_table.html

This file was deleted.

22 changes: 0 additions & 22 deletions _includes/v2.1/sql/diagrams/show_create_view.html

This file was deleted.

58 changes: 29 additions & 29 deletions v2.1/add-column.md
Expand Up @@ -6,7 +6,6 @@ toc: true

The `ADD COLUMN` [statement](sql-statements.html) is part of `ALTER TABLE` and adds columns to tables.


## Synopsis

<div>
Expand All @@ -19,7 +18,6 @@ The user must have the `CREATE` [privilege](privileges.html) on the table.

## Parameters


Parameter | Description
-----------|-------------
`table_name` | The name of the table to which you want to add the column.
Expand All @@ -46,13 +44,14 @@ The user must have the `CREATE` [privilege](privileges.html) on the table.
~~~

~~~
+-----------+-------------------+-------+---------+-----------+
| Field | Type | Null | Default | Indices |
+-----------+-------------------+-------+---------+-----------+
| id | INT | false | NULL | {primary} |
| balance | DECIMAL | true | NULL | {} |
| names | STRING | true | NULL | {} |
+-----------+-------------------+-------+---------+-----------+
+-------------+-----------+-------------+----------------+-----------------------+-------------+
| column_name | data_type | is_nullable | column_default | generation_expression | indices |
+-------------+-----------+-------------+----------------+-----------------------+-------------+
| id | INT | false | NULL | | {"primary"} |
| balance | DECIMAL | true | NULL | | {} |
| names | STRING | true | NULL | | {} |
+-------------+-----------+-------------+----------------+-----------------------+-------------+
(3 rows)
~~~

### Add multiple columns
Expand All @@ -68,16 +67,16 @@ The user must have the `CREATE` [privilege](privileges.html) on the table.
~~~

~~~
+-----------+-------------------+-------+---------+-----------+
| Field | Type | Null | Default | Indices |
+-----------+-------------------+-------+---------+-----------+
| id | INT | false | NULL | {primary} |
| balance | DECIMAL | true | NULL | {} |
| names | STRING | true | NULL | {} |
| location | STRING | true | NULL | {} |
| amount | DECIMAL | true | NULL | {} |
+-----------+-------------------+-------+---------+-----------+
+-------------+-----------+-------------+----------------+-----------------------+-------------+
| column_name | data_type | is_nullable | column_default | generation_expression | indices |
+-------------+-----------+-------------+----------------+-----------------------+-------------+
| id | INT | false | NULL | | {"primary"} |
| balance | DECIMAL | true | NULL | | {} |
| names | STRING | true | NULL | | {} |
| location | STRING | true | NULL | | {} |
| amount | DECIMAL | true | NULL | | {} |
+-------------+-----------+-------------+----------------+-----------------------+-------------+
(5 rows)
~~~

### Add a column with a `NOT NULL` constraint and a `DEFAULT` value
Expand All @@ -92,16 +91,17 @@ The user must have the `CREATE` [privilege](privileges.html) on the table.
> SHOW COLUMNS FROM accounts;
~~~
~~~
+-----------+-------------------+-------+---------------------------+-----------+
| Field | Type | Null | Default | Indices |
+-----------+-------------------+-------+---------------------------+-----------+
| id | INT | false | NULL | {primary} |
| balance | DECIMAL | true | NULL | {} |
| names | STRING | true | NULL | {} |
| location | STRING | true | NULL | {} |
| amount | DECIMAL | true | NULL | {} |
| interest | DECIMAL | false | ('1.3':::STRING::DECIMAL) | {} |
+-----------+-------------------+-------+---------------------------+-----------+
+-------------+-----------+-------------+------------------------+-----------------------+-------------+
| column_name | data_type | is_nullable | column_default | generation_expression | indices |
+-------------+-----------+-------------+------------------------+-----------------------+-------------+
| id | INT | false | NULL | | {"primary"} |
| balance | DECIMAL | true | NULL | | {} |
| names | STRING | true | NULL | | {} |
| location | STRING | true | NULL | | {} |
| amount | DECIMAL | true | NULL | | {} |
| interest | DECIMAL | false | 1.3:::DECIMAL::DECIMAL | | {} |
+-------------+-----------+-------------+------------------------+-----------------------+-------------+
(6 rows)
~~~

### Add a column with `NOT NULL` and `UNIQUE` constraints
Expand Down
4 changes: 2 additions & 2 deletions v2.1/add-constraint.md
Expand Up @@ -65,7 +65,7 @@ For example, let's say you have two tables, `orders` and `customers`:

{% include copy-clipboard.html %}
~~~ sql
> SHOW CREATE TABLE customers;
> SHOW CREATE customers;
~~~

~~~
Expand All @@ -85,7 +85,7 @@ For example, let's say you have two tables, `orders` and `customers`:

{% include copy-clipboard.html %}
~~~ sql
> SHOW CREATE TABLE orders;
> SHOW CREATE orders;
~~~

~~~
Expand Down
2 changes: 1 addition & 1 deletion v2.1/alter-view.md
Expand Up @@ -73,5 +73,5 @@ Parameter | Description

- [Views](views.html)
- [`CREATE VIEW`](create-view.html)
- [`SHOW CREATE VIEW`](show-create-view.html)
- [`SHOW CREATE`](show-create.html)
- [`DROP VIEW`](drop-view.html)
15 changes: 8 additions & 7 deletions v2.1/bool.md
Expand Up @@ -37,13 +37,14 @@ A `BOOL` value is 1 byte in width, but the total storage size is likely to be la
~~~

~~~
+-------+------+-------+---------+
| Field | Type | Null | Default |
+-------+------+-------+---------+
| a | INT | false | NULL |
| b | BOOL | true | NULL |
| c | BOOL | true | NULL |
+-------+------+-------+---------+
+-------------+-----------+-------------+----------------+-----------------------+-------------+
| column_name | data_type | is_nullable | column_default | generation_expression | indices |
+-------------+-----------+-------------+----------------+-----------------------+-------------+
| a | INT | false | NULL | | {"primary"} |
| b | BOOL | true | NULL | | {} |
| c | BOOL | true | NULL | | {} |
+-------------+-----------+-------------+----------------+-----------------------+-------------+
(3 rows)
~~~

{% include copy-clipboard.html %}
Expand Down
10 changes: 5 additions & 5 deletions v2.1/build-a-go-app-with-cockroachdb-gorm.md
Expand Up @@ -69,11 +69,11 @@ $ cockroach sql --insecure -e 'SHOW TABLES' --database=bank
~~~

~~~
+----------+
| Table |
+----------+
| accounts |
+----------+
+------------+
| table_name |
+------------+
| accounts |
+------------+
(1 row)
~~~

Expand Down
10 changes: 5 additions & 5 deletions v2.1/build-a-nodejs-app-with-cockroachdb-sequelize.md
Expand Up @@ -68,11 +68,11 @@ $ cockroach sql --insecure -e 'SHOW TABLES' --database=bank
~~~

~~~
+----------+
| Table |
+----------+
| accounts |
+----------+
+------------+
| table_name |
+------------+
| accounts |
+------------+
(1 row)
~~~

Expand Down
34 changes: 17 additions & 17 deletions v2.1/cancel-session.md
Expand Up @@ -33,13 +33,13 @@ In this example, we use the [`SHOW SESSIONS`](show-sessions.html) statement to g
> SHOW SESSIONS;
~~~
~~~
+---------+----------------------------------+----------+...
| node_id | session_id | username |...
+---------+----------------------------------+----------+...
| 1 | 1530c309b1d8d5f00000000000000001 | root |...
+---------+----------------------------------+----------+...
| 1 | 1530fe0e46d2692e0000000000000001 | maxroach |...
+---------+----------------------------------+----------+...
+---------+----------------------------------+-----------+...
| node_id | session_id | user_name |...
+---------+----------------------------------+-----------+...
| 1 | 1530c309b1d8d5f00000000000000001 | root |...
+---------+----------------------------------+-----------+...
| 1 | 1530fe0e46d2692e0000000000000001 | maxroach |...
+---------+----------------------------------+-----------+...
~~~

{% include copy-clipboard.html %}
Expand All @@ -64,23 +64,23 @@ Use the [`SHOW SESSIONS`](show-sessions.html) statement to view all active sessi
> SHOW SESSIONS;
~~~
~~~
+---------+----------------------------------+----------+...
| node_id | session_id | username |...
+---------+----------------------------------+----------+...
| 1 | 1530c309b1d8d5f00000000000000001 | root |...
+---------+----------------------------------+----------+...
| 1 | 1530fe0e46d2692e0000000000000001 | maxroach |...
+---------+----------------------------------+----------+...
| 1 | 15310cc79671fc6a0000000000000001 | maxroach |...
+---------+----------------------------------+----------+...
+---------+----------------------------------+-----------+...
| node_id | session_id | user_name |...
+---------+----------------------------------+-----------+...
| 1 | 1530c309b1d8d5f00000000000000001 | root |...
+---------+----------------------------------+-----------+...
| 1 | 1530fe0e46d2692e0000000000000001 | maxroach |...
+---------+----------------------------------+-----------+...
| 1 | 15310cc79671fc6a0000000000000001 | maxroach |...
+---------+----------------------------------+-----------+...
~~~

To cancel multiple sessions, nest a [`SELECT` clause](select-clause.html) that retrieves `session_id`(s) inside the `CANCEL SESSIONS` statement:

{% include copy-clipboard.html %}
~~~ sql
> CANCEL SESSIONS (SELECT session_id FROM [SHOW SESSIONS]
WHERE username = 'maxroach');
WHERE user_name = 'maxroach');
~~~

All sessions created by `maxroach` will be cancelled.
Expand Down
13 changes: 8 additions & 5 deletions v2.1/cluster-setup-troubleshooting.md
Expand Up @@ -66,11 +66,14 @@ Proceed through the following steps until you locate the source of the issue wit
You should receive a response that looks similar to this:

~~~
+--------------------+
| Database |
+--------------------+
| system |
+--------------------+
+---------------+
| database_name |
+---------------+
| defaultdb |
| postgres |
| system |
+---------------+
(3 rows)
~~~

Errors at this stage potentially include:
Expand Down
2 changes: 1 addition & 1 deletion v2.1/column-families.md
Expand Up @@ -36,7 +36,7 @@ For example, let's say we want to create a table to store an immutable blob of d

{% include copy-clipboard.html %}
~~~ sql
> SHOW CREATE TABLE users;
> SHOW CREATE users;
~~~

~~~
Expand Down

0 comments on commit c262afa

Please sign in to comment.