Skip to content

Commit 995459e

Browse files
author
TianyuZhang1214
authored
doc: managing multiple databases (#327)
1 parent 062442f commit 995459e

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,13 @@ Looking to load Parquet files into MyDuck Server and start querying? Follow our
201201

202202
Already have a DuckDB file? You can seamlessly bootstrap MyDuck Server with it. See our [DuckDB file bootstrapping guide](docs/tutorial/bootstrap.md) for more details.
203203

204+
### Managing Multiple Databases
205+
206+
Easily manage multiple databases in MyDuck Server, same as Postgres. For step-by-step instructions and detailed guidance, check out our [Database Management Guide](docs/tutorial/manage-multiple-databases.md).
207+
204208
### Backup and Restore with Object Storage
205209

206-
To back up and restore your MyDuck Server database using object storage, refer to our [backup and restore guide](docs/tutorial/backup-restore.md) for detailed instructions.
210+
To back up and restore your databases inside MyDuck Server using object storage, refer to our [backup and restore guide](docs/tutorial/backup-restore.md) for detailed instructions.
207211

208212
### LLM Integration
209213

@@ -217,8 +221,8 @@ MyDuck Server can be seamlessly accessed from the Python data science ecosystem.
217221

218222
We have big plans for MyDuck Server! Here are some of the features we’re working on:
219223

220-
- [ ] Arrow Flight SQL.
221-
- [ ] Multiple DB.
224+
- [x] Arrow Flight SQL.
225+
- [x] Multiple DB.
222226
- [ ] Authentication.
223227
- [ ] ...and more! We’re always looking for ways to make MyDuck Server better. If you have a feature request, please let us know by [opening an issue](https://github.com/apecloud/myduckserver/issues/new).
224228

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
### Managing Databases in MyDuck Server
2+
3+
MyDuck Server offers basic database operations similar to PostgreSQL. Each database in MyDuck Server is represented as a single DuckDB data file. As a result, all database operations are mapped to corresponding file operations. Below are the key commands for managing databases in MyDuck Server:
4+
5+
#### 1. `CREATE DATABASE`
6+
The `CREATE DATABASE db_name` command creates a new database by generating a file named `db_name.db`. This database is then attached to the current DuckDB client session.
7+
8+
**Example:**
9+
```sql
10+
CREATE DATABASE my_database;
11+
```
12+
13+
This will create a new database file `my_database.db` and attach it to the current session.
14+
15+
#### 2. `DROP DATABASE`
16+
The `DROP DATABASE db_name` command detaches the specified database from the current session and deletes the associated database file (`db_name.db`).
17+
18+
**Example:**
19+
```sql
20+
DROP DATABASE my_database;
21+
```
22+
23+
This will detach `my_database` from the current session and permanently delete the file `my_database.db` from storage.
24+
25+
#### 3. `USE DATABASE`
26+
The `USE db_name` command allows you to switch the current session to a different database. After executing this command, all subsequent operations will be performed on the specified database.
27+
28+
**Example:**
29+
```sql
30+
USE my_database;
31+
```
32+
33+
This command switches the current session to the `my_database` database, and all further queries will be executed on it.
34+
35+
---
36+
37+
### Important Notes
38+
39+
- This feature is available only through the PostgreSQL protocol.
40+
- To backup your database to object storage or restore it from a backup file, please refer to the [Backup and Restore Guide](./backup-restore.md).

logo/MyDuck.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)