ALTER DATABASE
Introduced or updated: v1.2.955
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 (
<database_option> = '<value>' [, ...]
)
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. |
DEFAULT_S3_STORAGE_CLASS | The default S3 storage class for new non-temporary external Fuse tables. Accepts standard or intelligent_tiering (case-insensitive). |
note
SET OPTIONSonly affects tables created after the statement is executed. Existing tables are not changed.- You can update the connection or path separately if the other option already exists on the database.
DEFAULT_S3_STORAGE_CLASScan be set independently. It applies only to new non-temporary external Fuse tables without an explicitS3_STORAGE_CLASS. To change an existing table, useALTER TABLE ... SET OPTIONS. See External Tables for examples.
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/'
);
Set the default S3 storage class
ALTER DATABASE external_analytics SET OPTIONS (
DEFAULT_S3_STORAGE_CLASS = 'standard'
);
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;