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

6
# SHOW Statements {#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 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
Prints a list of all databases.

```sql
SHOW DATABASES [LIKE | ILIKE | NOT LIKE '<pattern>'] [LIMIT <N>] [INTO OUTFILE filename] [FORMAT format]
```

This statement is identical to the query:

```sql
SELECT name FROM system.databases [WHERE name LIKE | ILIKE | NOT LIKE '<pattern>'] [LIMIT <N>] [INTO OUTFILE filename] [FORMAT format]
```

### Examples {#examples}

Getting database names, containing the symbols sequence 'de' in their names:

34
``` sql
35
SHOW DATABASES LIKE '%de%'
36 37
```

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
Result:

``` text
┌─name────┐
│ default │
└─────────┘
```

Getting database names, containing symbols sequence 'de' in their names, in the case insensitive manner:

``` sql
SHOW DATABASES ILIKE '%DE%'
```

Result:

``` text
┌─name────┐
│ default │
└─────────┘
```

Getting database names, not containing the symbols sequence 'de' in their names:

``` sql
SHOW DATABASES NOT LIKE '%de%'
```

Result:

``` text
┌─name───────────────────────────┐
│ _temporary_and_external_tables │
│ system                         │
│ test                           │
│ tutorial                       │
└────────────────────────────────┘
```

Getting the first two rows from database names:

``` sql
SHOW DATABASES LIMIT 2
```

Result:

``` text
┌─name───────────────────────────┐
│ _temporary_and_external_tables │
│ default                        │
└────────────────────────────────┘
```

### See Also {#see-also}

-   [CREATE DATABASE](https://clickhouse.tech/docs/en/sql-reference/statements/create/database/#query-language-create-database)
95

96
## SHOW PROCESSLIST {#show-processlist}
97

98
``` sql
99 100 101
SHOW PROCESSLIST [INTO OUTFILE filename] [FORMAT format]
```

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

104
The `SELECT * FROM system.processes` query returns data about all the current queries.
105 106 107

Tip (execute in the console):

108
``` bash
109 110 111
$ watch -n1 "clickhouse-client --query='SHOW PROCESSLIST'"
```

112
## SHOW TABLES {#show-tables}
113 114 115

Displays a list of tables.

116 117
```sql
SHOW [TEMPORARY] TABLES [{FROM | IN} <db>] [LIKE | ILIKE | NOT LIKE '<pattern>'] [LIMIT <N>] [INTO OUTFILE <filename>] [FORMAT <format>]
118 119 120 121
```

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

122 123 124 125 126 127 128 129 130
This statement is identical to the query:

```sql
SELECT name FROM system.tables [WHERE name LIKE | ILIKE | NOT LIKE '<pattern>'] [LIMIT <N>] [INTO OUTFILE <filename>] [FORMAT <format>]
```

### Examples {#examples}

Getting table names, containing the symbols sequence 'user' in their names:
131

132
``` sql
133
SHOW TABLES FROM system LIKE '%user%'
134 135
```

136
Result:
137

138 139 140 141 142 143 144 145
``` text
┌─name─────────────┐
│ user_directories │
│ users            │
└──────────────────┘
```

Getting table names, containing sequence 'user' in their names, in the case insensitive manner:
146

147
``` sql
148
SHOW TABLES FROM system ILIKE '%USER%'
149
```
150

151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
Result:

``` text
┌─name─────────────┐
│ user_directories │
│ users            │
└──────────────────┘
```

Getting table names, not containing the symbol sequence 's' in their names:

``` sql
SHOW TABLES FROM system NOT LIKE '%s%'
```

Result:

``` text
┌─name─────────┐
│ metric_log   │
│ metric_log_0 │
│ metric_log_1 │
└──────────────┘
```

Getting the first two rows from table names:

``` sql
SHOW TABLES FROM system LIMIT 2
```

Result:

184
``` text
185 186
┌─name───────────────────────────┐
│ aggregate_function_combinators │
187
│ asynchronous_metric_log        │
188 189
└────────────────────────────────┘
```
190

191 192 193 194 195
### See Also {#see-also}

-   [Create Tables](https://clickhouse.tech/docs/en/getting-started/tutorial/#create-tables)
-   [SHOW CREATE TABLE](https://clickhouse.tech/docs/en/sql-reference/statements/show/#show-create-table)

196
## SHOW DICTIONARIES {#show-dictionaries}
197

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

200
``` sql
201 202 203 204 205 206 207
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:

208
``` sql
209 210 211 212 213
SELECT name FROM system.dictionaries WHERE database = <db> [AND name LIKE <pattern>] [LIMIT <N>] [INTO OUTFILE <filename>] [FORMAT <format>]
```

**Example**

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

216
``` sql
217 218
SHOW DICTIONARIES FROM db LIKE '%reg%' LIMIT 2
```
219 220

``` text
221 222 223 224 225
┌─name─────────┐
│ regions      │
│ region_names │
└──────────────┘
```
226

227 228 229 230 231 232 233 234 235 236 237 238 239 240
## 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}

241
Shows parameters that were used at a [user creation](../../sql-reference/statements/create/user.md).
242

243
`SHOW CREATE USER` doesn’t output user passwords.
244 245 246 247 248 249 250 251 252

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

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

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

253
Shows parameters that were used at a [role creation](../../sql-reference/statements/create/role.md).
254 255 256 257 258 259 260 261 262

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

``` sql
SHOW CREATE ROLE name
```

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

263
Shows parameters that were used at a [row policy creation](../../sql-reference/statements/create/row-policy.md).
264 265 266

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

267
``` sql
268 269 270 271 272
SHOW CREATE [ROW] POLICY name ON [database.]table
```

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

273
Shows parameters that were used at a [quota creation](../../sql-reference/statements/create/quota.md).
274

275
### Syntax {#show-create-quota-syntax}
276

277
``` sql
278 279 280 281 282
SHOW CREATE QUOTA [name | CURRENT]
```

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

283
Shows parameters that were used at a [settings profile creation](../../sql-reference/statements/create/settings-profile.md).
284

285
### Syntax {#show-create-settings-profile-syntax}
286

287
``` sql
288 289 290
SHOW CREATE [SETTINGS] PROFILE name
```

291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
## SHOW USERS {#show-users-statement}

Returns a list of [user account](../../operations/access-rights.md#user-account-management) names. To view user accounts parameters, see the system table [system.users](../../operations/system-tables/users.md#system_tables-users).

### Syntax {#show-users-syntax}

``` sql
SHOW USERS
```
 
## SHOW ROLES {#show-roles-statement}

Returns a list of [roles](../../operations/access-rights.md#role-management). To view another parameters, see system tables [system.roles](../../operations/system-tables/roles.md#system_tables-roles) and [system.role-grants](../../operations/system-tables/role-grants.md#system_tables-role_grants).

### Syntax {#show-roles-syntax}

``` sql
SHOW [CURRENT|ENABLED] ROLES
```

## SHOW PROFILES {#show-profiles-statement}

Returns a list of [setting profiles](../../operations/access-rights.md#settings-profiles-management). To view user accounts parameters, see the system table [settings_profiles](../../operations/system-tables/settings_profiles.md#system_tables-settings_profiles).

### Syntax {#show-profiles-syntax}

``` sql
SHOW [SETTINGS] PROFILES
```

## SHOW POLICIES {#show-policies-statement}

Returns a list of [row policies](../../operations/access-rights.md#row-policy-management) for the specified table. To view user accounts parameters, see the system table [system.row_policies](../../operations/system-tables/row_policies.md#system_tables-row_policies).

### Syntax {#show-policies-syntax}

``` sql
SHOW [ROW] POLICIES [ON [db.]table]
```

## SHOW QUOTAS {#show-quotas-statement}

Returns a list of [quotas](../../operations/access-rights.md#quotas-management). To view quotas parameters, see the system table [system.quotas](../../operations/system-tables/quotas.md#system_tables-quotas).

### Syntax {#show-quotas-syntax}

``` sql
SHOW QUOTAS
```  
    
## SHOW QUOTA {#show-quota-statement}

Returns a [quota](../../operations/quotas.md) consumption for all users or for current user. To view another parameters, see system tables [system.quotas_usage](../../operations/system-tables/quotas_usage.md#system_tables-quotas_usage) and [system.quota_usage](../../operations/system-tables/quota_usage.md#system_tables-quota_usage).

### Syntax {#show-quota-syntax}

``` sql
SHOW [CURRENT] QUOTA
```

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