ALTER DATABASE (SQL Analytics)ALTER DATABASE (SQL Analytics)

通过设置 DBPROPERTIES 更改与数据库关联的元数据。Alters metadata associated with a database by setting DBPROPERTIES. 指定的属性值将替代具有相同属性名的任何现有值。The specified property values override any existing value with the same property name. SCHEMADATABASE 可互换使用,可用一个替代另一个。The usage of SCHEMA and DATABASE are interchangeable and one can be used in place of the other. 如果在系统中找不到该数据库,则系统会发出一条错误消息。An error message is issued if the database is not found in the system. 此命令主要用于记录数据库的元数据,可用于审核目的。This command is mostly used to record the metadata for a database and may be used for auditing purposes.

语法Syntax

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

参数Parameters

  • database_namedatabase_name

    要更改的数据库的名称。The name of the database to be altered.

示例Examples

-- Creates a database named `inventory`.
CREATE DATABASE inventory;

-- Alters the database to set properties `Edited-by` and `Edit-date`.
ALTER DATABASE inventory SET DBPROPERTIES ('Edited-by' = 'John', 'Edit-date' = '01/01/2001');

-- Verify that properties are set.
DESCRIBE DATABASE EXTENDED inventory;
+-------------------------+------------------------------------------+
|database_description_item|                database_description_value|
+-------------------------+------------------------------------------+
|            Database Name|                                 inventory|
|              Description|                                          |
|                 Location|   file:/temp/spark-warehouse/inventory.db|
|               Properties|((Edit-date,01/01/2001), (Edited-by,John))|
+-------------------------+------------------------------------------+