Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _data/sidebar_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ entries:
- title: <code>SHOW CREATE TABLE</code>
url: /show-create-table.html

- title: <code>SHOW DATABASE</code>
url: /show-database.html

- title: <code>SHOW DATABASES</code>
url: /show-databases.html

Expand Down
14 changes: 14 additions & 0 deletions _includes/sql/diagrams/show_database.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<svg width="232" 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="64" height="32" rx="10"></rect>
<rect x="29" y="1" width="64" height="32" class="terminal" rx="10"></rect>
<text class="terminal" x="39" y="21">SHOW</text>
<rect x="115" y="3" width="90" height="32" rx="10"></rect>
<rect x="113" y="1" width="90" height="32" class="terminal" rx="10"></rect>
<text class="terminal" x="123" y="21">DATABASE</text>
<path class="line" d="m17 17 h2 m0 0 h10 m64 0 h10 m0 0 h10 m90 0 h10 m3 0 h-3"></path>
<polygon points="223 17 231 13 231 21"></polygon>
<polygon points="223 17 215 13 215 21"></polygon>
</svg>
1 change: 1 addition & 0 deletions generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ func main() {
{name: "show_columns", stmt: "show_stmt", match: regexp.MustCompile("'SHOW' 'COLUMNS'"), replace: map[string]string{"var_name": "table_name"}, unlink: []string{"table_name"}},
{name: "show_constraints", stmt: "show_stmt", match: regexp.MustCompile("'SHOW' 'CONSTRAINTS'"), replace: map[string]string{"var_name": "table_name"}, unlink: []string{"table_name"}},
{name: "show_create_table", stmt: "show_stmt", match: regexp.MustCompile("'SHOW' 'CREATE' 'TABLE'"), replace: map[string]string{"var_name": "table_name"}, unlink: []string{"table_name"}},
{name: "show_database", stmt: "show_stmt", match: regexp.MustCompile("'SHOW' 'DATABASE'")},
{name: "show_databases", stmt: "show_stmt", match: regexp.MustCompile("'SHOW' 'DATABASES'")},
{name: "show_grants", stmt: "show_stmt", inline: []string{"on_privilege_target_clause", "privilege_target", "for_grantee_clause", "grantee_list"}, match: regexp.MustCompile("'SHOW' 'GRANTS'")},
{name: "show_index", stmt: "show_stmt", match: regexp.MustCompile("'SHOW' 'INDEX'"), replace: map[string]string{"var_name": "table_name"}, unlink: []string{"table_name"}},
Expand Down
42 changes: 42 additions & 0 deletions show-database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: SHOW DATABASE
summary: The SHOW DATABASE statement lists the default database for the current session.
toc: false
---

The `SHOW DATABASE` [statement](sql-statements.html) lists the default database for the current session.

<div id="toc"></div>

## Synopsis

{% include sql/diagrams/show_database.html %}

## Required Privileges

No [privileges](privileges.html) are required to list the default database.

## Example

~~~ shell
$ cockroach sql --database=test
# Welcome to the cockroach SQL interface.
# All statements must be terminated by a semicolon.
# To exit: CTRL + D.
~~~
~~~ sql
> SHOW DATABASE;
~~~
~~~
+----------+
| DATABASE |
+----------+
| test |
+----------+
(1 row)
~~~

## See Also

- [`SET DATABASE`](set-database.html)
- [Other SQL Statements](sql-statements.html)
1 change: 1 addition & 0 deletions sql-statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Statement | Usage
[`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 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.
Expand Down