ALTER DATABASE
Introduced or updated: v1.2.866
Changes the name of a database, or sets default storage options for a database.
Syntax
-- Rename a database
ALTER DATABASE [ IF EXISTS ] <name> RENAME TO <new_db_name>
-- Set default storage options
ALTER DATABASE [ IF EXISTS ] <name> SET OPTIONS (
DEFAULT_STORAGE_CONNECTION = '<connection_name>'
| DEFAULT_STORAGE_PATH = '<path>'
)
Parameters
| Parameter | Description |
|---|---|
DEFAULT_STORAGE_CONNECTION | The name of an existing connection (created via CREATE CONNECTION) to use as the default storage connection for tables in this database. |
DEFAULT_STORAGE_PATH | The default storage path URI (e.g., s3://bucket/path/) for tables in this database. Must end with / and match the connection's storage type. |
note
SET OPTIONSonly affects tables created after the statement is executed. Existing tables are not changed.- You can update one option at a time, as long as the other option already exists on the database.
Examples
Rename a database
CREATE DATABASE DATABEND;
SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| DATABEND |
| information_schema |
| default |
| system |
+--------------------+
ALTER DATABASE `DATABEND` RENAME TO `NEW_DATABEND`;
SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| NEW_DATABEND |
| default |
| system |
+--------------------+
Set default storage options
ALTER DATABASE analytics SET OPTIONS (
DEFAULT_STORAGE_CONNECTION = 'my_s3',
DEFAULT_STORAGE_PATH = 's3://mybucket/analytics_v2/'
);
Tag Operations
Assigns or removes tags on a database. Tags must be created with CREATE TAG first. For full details, see SET TAG / UNSET TAG.
Syntax
ALTER DATABASE [ IF EXISTS ] <name> SET TAG <tag_name> = '<value>' [, <tag_name> = '<value>' ...]
ALTER DATABASE [ IF EXISTS ] <name> UNSET TAG <tag_name> [, <tag_name> ...]
Examples
ALTER DATABASE mydb SET TAG env = 'prod', owner = 'team_a';
ALTER DATABASE mydb UNSET TAG env, owner;