Updated on 2026-11-06 GMT+08:00

Alter Database Properties

Function

The ALTER DATABASE statement is used to modify the properties or location of a database. The DATABASE, SCHEMA, and NAMESPACE keywords are interchangeable. If the database does not exist, an error is reported.

Syntax

Set properties

ALTER { DATABASE | SCHEMA | NAMESPACE } database_name
    SET { DBPROPERTIES | PROPERTIES } ( property_name = property_value [, ...] )

Unset properties

ALTER { DATABASE | SCHEMA | NAMESPACE } database_name
    UNSET { DBPROPERTIES | PROPERTIES } ( property_name [, ...] )

Modify location

ALTER { DATABASE | SCHEMA | NAMESPACE } database_name
    SET LOCATION 'new_location'

Keywords

  • DATABASE/SCHEMA/NAMESPACE: All three are equivalent and interchangeable. DATABASE is recommended.
  • SET DBPROPERTIES/SET PROPERTIES: Sets database properties. DBPROPERTIES and PROPERTIES are equivalent.
  • UNSET DBPROPERTIES/UNSET PROPERTIES: Removes database properties. If the specified property does not exist, the command ignores it and executes successfully.
  • SET LOCATION: Modifies the default storage location of the database.

Parameters

Table 1 Parameter descriptions

Parameter

Mandatory

Description

database_name

Yes

The name of the database to alter.

SET DBPROPERTIES / SET PROPERTIES

Yes

Sets database properties. The specified property value overwrites the existing property value with the same name. Primarily used to record database metadata information.

UNSET DBPROPERTIES / UNSET PROPERTIES

Yes

Removes database properties. If the specified property does not exist, the command ignores it and executes successfully.

property_name

Yes

Property name.

property_value

Yes (for SET)

Property value.

SET LOCATION

Yes

Modifies the default storage location of the database. Does not move data from the current database directory to the new location, and does not affect the location of existing tables/partitions under the database.

Precautions

  • Modifying the database location does not automatically migrate existing data. It only affects the default location for newly created tables in the future.
  • The path for SET LOCATION must be in OBS format (e.g., obs://bucket-name/path/).
  • The DATABASE, SCHEMA, and NAMESPACE keywords are interchangeable. DATABASE is recommended.
  • The DBPROPERTIES and PROPERTIES keywords are interchangeable.
  • Use DESCRIBE DATABASE EXTENDED to verify the results of property and location modifications.

Example 1: Set Database Properties

Create database inventory and set properties.

CREATE DATABASE IF NOT EXISTS inventory
  LOCATION 'obs://my-bucket/inventory/';

ALTER DATABASE inventory SET DBPROPERTIES ('Edited-by' = 'John', 'Edit-date' = '01/01/2001');

Verify properties:

DESCRIBE DATABASE EXTENDED inventory; 

Example result:

database_description_item

database_description_value

Database Name

inventory

Location

obs://my-bucket/inventory/

Properties

((Edit-date,01/01/2001), (Edited-by,John))

Example 2: Modify Database Location

ALTER DATABASE inventory SET LOCATION 'obs://my-bucket/new-inventory/'; 

Verify new location:

DESCRIBE DATABASE EXTENDED inventory; 

Example 3: Remove Database Properties

ALTER DATABASE inventory UNSET DBPROPERTIES ('Edited-by'); 

Removing a non-existent property is ignored and the command executes successfully:

ALTER DATABASE inventory UNSET DBPROPERTIES ('non-existent'); 

Example 4: Use SCHEMA/NAMESPACE Keywords

SCHEMA and NAMESPACE are equivalent to DATABASE and can be used interchangeably.

ALTER SCHEMA inventory SET DBPROPERTIES ('Owner' = 'Admin');  
ALTER NAMESPACE inventory SET DBPROPERTIES ('Department' = 'Engineering');