show.md 4.6 KB
Newer Older
I
Ivan Blinkov 已提交
1 2 3 4 5
---
toc_priority: 38
toc_title: SHOW
---

6
# SHOW Queries {#show-queries}
7

8
## SHOW CREATE TABLE {#show-create-table}
9

10
``` sql
11
SHOW CREATE [TEMPORARY] [TABLE|DICTIONARY] [db.]table [INTO OUTFILE filename] [FORMAT format]
12 13
```

14
Returns a single `String`-type ‘statement’ column, which contains a single value – the `CREATE` query used for creating the specified object.
15

I
Ivan Blinkov 已提交
16
## SHOW DATABASES {#show-databases}
17

18
``` sql
19 20 21 22 23 24
SHOW DATABASES [INTO OUTFILE filename] [FORMAT format]
```

Prints a list of all databases.
This query is identical to `SELECT name FROM system.databases [INTO OUTFILE filename] [FORMAT format]`.

25
## SHOW PROCESSLIST {#show-processlist}
26

27
``` sql
28 29 30
SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format]
```

31
Outputs the content of the [system.processes](../../operations/system-tables.md#system_tables-processes) table, that contains a list of queries that is being processed at the moment, excepting `SHOW PROCESSLIST` queries.
32

33
The `SELECT * FROM system.processes` query returns data about all the current queries.
34 35 36

Tip (execute in the console):

37
``` bash
38 39 40
$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'"
```

41
## SHOW TABLES {#show-tables}
42 43 44

Displays a list of tables.

45
``` sql
S
sundy-li 已提交
46
SHOW [TEMPORARY] TABLES [{FROM | IN} <db>] [LIKE '<pattern>' | WHERE expr] [LIMIT <N>] [INTO OUTFILE <filename>] [FORMAT <format>]
47 48 49 50
```

If the `FROM` clause is not specified, the query returns the list of tables from the current database.

51
You can get the same results as the `SHOW TABLES` query in the following way:
52

53
``` sql
54 55 56 57 58 59 60
SELECT name FROM system.tables WHERE database = <db> [AND name LIKE <pattern>] [LIMIT <N>] [INTO OUTFILE <filename>] [FORMAT <format>]
```

**Example**

The following query selects the first two rows from the list of tables in the `system` database, whose names contain `co`.

61
``` sql
62 63
SHOW TABLES FROM system LIKE '%co%' LIMIT 2
```
64 65

``` text
66 67 68 69 70
┌─name───────────────────────────┐
│ aggregate_function_combinators │
│ collations                     │
└────────────────────────────────┘
```
71

72
## SHOW DICTIONARIES {#show-dictionaries}
73

74
Displays a list of [external dictionaries](../../sql-reference/dictionaries/external-dictionaries/external-dicts.md).
75

76
``` sql
77 78 79 80 81 82 83
SHOW DICTIONARIES [FROM <db>] [LIKE '<pattern>'] [LIMIT <N>] [INTO OUTFILE <filename>] [FORMAT <format>]
```

If the `FROM` clause is not specified, the query returns the list of dictionaries from the current database.

You can get the same results as the `SHOW DICTIONARIES` query in the following way:

84
``` sql
85 86 87 88 89
SELECT name FROM system.dictionaries WHERE database = <db> [AND name LIKE <pattern>] [LIMIT <N>] [INTO OUTFILE <filename>] [FORMAT <format>]
```

**Example**

90
The following query selects the first two rows from the list of tables in the `system` database, whose names contain `reg`.
91

92
``` sql
93 94
SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2
```
95 96

``` text
97 98 99 100 101
┌─name─────────┐
│ regions      │
│ region_names │
└──────────────┘
```
102

103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133

## SHOW GRANTS {#show-grants-statement}

Shows privileges for a user.

### Syntax {#show-grants-syntax}

``` sql
SHOW GRANTS [FOR user]
```

If user is not specified, the query returns privileges for the current user.



## SHOW CREATE USER {#show-create-user-statement}

Shows parameters that were used at a [user creation](create.md#create-user-statement).

`SHOW CREATE USER` doesn't output user passwords.

### Syntax {#show-create-user-syntax}

``` sql
SHOW CREATE USER [name | CURRENT_USER]
```



## SHOW CREATE ROLE {#show-create-role-statement}

134
Shows parameters that were used at a [role creation](create.md#create-role-statement).
135 136 137 138 139 140 141 142 143 144 145

### Syntax {#show-create-role-syntax}

``` sql
SHOW CREATE ROLE name
```



## SHOW CREATE ROW POLICY {#show-create-row-policy-statement}

146
Shows parameters that were used at a [row policy creation](create.md#create-row-policy-statement).
147 148 149 150 151 152 153 154 155 156

### Syntax {#show-create-row-policy-syntax}

```sql
SHOW CREATE [ROW] POLICY name ON [database.]table
```


## SHOW CREATE QUOTA {#show-create-quota-statement}

157
Shows parameters that were used at a [quota creation](create.md#create-quota-statement).
158 159 160 161 162 163 164 165 166 167

### Syntax {#show-create-row-policy-syntax}

```sql
SHOW CREATE QUOTA [name | CURRENT]
```


## SHOW CREATE SETTINGS PROFILE {#show-create-settings-profile-statement}

168
Shows parameters that were used at a [settings profile creation](create.md#create-settings-profile-statement).
169 170 171 172 173 174 175

### Syntax {#show-create-row-policy-syntax}

```sql
SHOW CREATE [SETTINGS] PROFILE name
```

176
[Original article](https://clickhouse.tech/docs/en/query_language/show/) <!--hide-->