Skip to content

Commit 7b17194

Browse files
committed
SHOW DROP DATABASES
1 parent c5bbae1 commit 7b17194

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: system.databases_with_history
3+
---
4+
5+
import FunctionDescription from '@site/src/components/FunctionDescription';
6+
7+
<FunctionDescription description="Introduced: v1.1.658"/>
8+
9+
Records all databases, including active and dropped ones. It shows each database's catalog, name, unique ID, owner (if specified), and the deletion timestamp (NULL if still active).
10+
11+
See also: [SHOW DROP DATABASES](../../10-sql-commands/00-ddl/00-database/show-drop-databases.md)
12+
13+
```sql
14+
SELECT * FROM system.databases_with_history;
15+
16+
┌────────────────────────────────────────────────────────────────────────────────────────────────────┐
17+
│ catalog │ name │ database_id │ owner │ dropped_on │
18+
├─────────┼────────────────────┼─────────────────────┼──────────────────┼────────────────────────────┤
19+
│ default │ system │ 4611686018427387905NULLNULL
20+
│ default │ information_schema │ 4611686018427387906NULLNULL
21+
│ default │ default │ 1NULLNULL
22+
│ default │ my_db │ 114NULL2024-11-15 02:44:46.207120
23+
└────────────────────────────────────────────────────────────────────────────────────────────────────┘
24+
```
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: SHOW DROP DATABASES
3+
---
4+
import FunctionDescription from '@site/src/components/FunctionDescription';
5+
6+
<FunctionDescription description="Introduced or updated: v1.2.658"/>
7+
8+
Lists all databases along with their deletion timestamps if they have been dropped, allowing users to review deleted databases and their details.
9+
10+
See also: [system.databases_with_history](../../../00-sql-reference/20-system-tables/system-databases-with-history.md)
11+
12+
## Syntax
13+
14+
```sql
15+
SHOW DROP DATABASES
16+
[ FROM <catalog> ]
17+
[ LIKE '<pattern>' | WHERE <expr> ]
18+
```
19+
20+
## Examples
21+
22+
```sql
23+
-- Create a new database named my_db
24+
CREATE DATABASE my_db;
25+
26+
-- Drop the database my_db
27+
DROP DATABASE my_db;
28+
29+
-- If a database has been dropped, dropped_on shows the deletion time;
30+
-- If it is still active, dropped_on is NULL.
31+
SHOW DROP DATABASES;
32+
33+
┌─────────────────────────────────────────────────────────────────────────────────┐
34+
│ catalog │ name │ database_id │ dropped_on │
35+
├─────────┼────────────────────┼─────────────────────┼────────────────────────────┤
36+
│ default │ default │ 1NULL
37+
│ default │ information_schema │ 4611686018427387906NULL
38+
│ default │ my_db │ 1142024-11-15 02:44:46.207120
39+
│ default │ system │ 4611686018427387905NULL
40+
└─────────────────────────────────────────────────────────────────────────────────┘
41+
```

0 commit comments

Comments
 (0)