Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: managing multiple databases #327

Merged
merged 5 commits into from
Dec 30, 2024
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
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,13 @@ Looking to load Parquet files into MyDuck Server and start querying? Follow our

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.

### Managing Multiple Databases

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).

### Backup and Restore with Object Storage

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.
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.

### LLM Integration

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

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

- [ ] Arrow Flight SQL.
- [ ] Multiple DB.
- [x] Arrow Flight SQL.
- [x] Multiple DB.
- [ ] Authentication.
- [ ] ...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).

Expand Down
40 changes: 40 additions & 0 deletions docs/tutorial/manage-multiple-databases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
### Managing Databases in MyDuck Server

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:

#### 1. `CREATE DATABASE`
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.

**Example:**
```sql
CREATE DATABASE my_database;
```

This will create a new database file `my_database.db` and attach it to the current session.

#### 2. `DROP DATABASE`
The `DROP DATABASE db_name` command detaches the specified database from the current session and deletes the associated database file (`db_name.db`).

**Example:**
```sql
DROP DATABASE my_database;
```

This will detach `my_database` from the current session and permanently delete the file `my_database.db` from storage.

#### 3. `USE DATABASE`
TianyuZhang1214 marked this conversation as resolved.
Show resolved Hide resolved
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.

**Example:**
```sql
USE my_database;
```

This command switches the current session to the `my_database` database, and all further queries will be executed on it.

---

### Important Notes

- This feature is available only through the PostgreSQL protocol.
- 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).
2 changes: 1 addition & 1 deletion logo/MyDuck.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading