Back to home page

OSCL-LXR

 
 

    


0001 ---
0002 layout: global
0003 title: ALTER DATABASE
0004 displayTitle: ALTER DATABASE
0005 license: |
0006   Licensed to the Apache Software Foundation (ASF) under one or more
0007   contributor license agreements.  See the NOTICE file distributed with
0008   this work for additional information regarding copyright ownership.
0009   The ASF licenses this file to You under the Apache License, Version 2.0
0010   (the "License"); you may not use this file except in compliance with
0011   the License.  You may obtain a copy of the License at
0012  
0013      http://www.apache.org/licenses/LICENSE-2.0
0014  
0015   Unless required by applicable law or agreed to in writing, software
0016   distributed under the License is distributed on an "AS IS" BASIS,
0017   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0018   See the License for the specific language governing permissions and
0019   limitations under the License.
0020 ---
0021 
0022 ### Description
0023 
0024 You can alter metadata associated with a database by setting `DBPROPERTIES`.  The specified property
0025 values override any existing value with the same property name. Please note that the usage of 
0026 `SCHEMA` and `DATABASE` are interchangeable and one can be used in place of the other. An error message
0027 is issued if the database is not found in the system. This command is mostly used to record the metadata
0028 for a database and may be used for auditing purposes.
0029 
0030 ### Syntax
0031 
0032 ```sql
0033 ALTER { DATABASE | SCHEMA } database_name
0034     SET DBPROPERTIES ( property_name = property_value [ , ... ] )
0035 ```
0036 
0037 ### Parameters
0038 
0039 * **database_name**
0040 
0041     Specifies the name of the database to be altered.
0042 
0043 ### Examples
0044 
0045 ```sql
0046 -- Creates a database named `inventory`.
0047 CREATE DATABASE inventory;
0048 
0049 -- Alters the database to set properties `Edited-by` and `Edit-date`.
0050 ALTER DATABASE inventory SET DBPROPERTIES ('Edited-by' = 'John', 'Edit-date' = '01/01/2001');
0051 
0052 -- Verify that properties are set.
0053 DESCRIBE DATABASE EXTENDED inventory;
0054 +-------------------------+------------------------------------------+
0055 |database_description_item|                database_description_value|
0056 +-------------------------+------------------------------------------+
0057 |            Database Name|                                 inventory|
0058 |              Description|                                          |
0059 |                 Location|   file:/temp/spark-warehouse/inventory.db|
0060 |               Properties|((Edit-date,01/01/2001), (Edited-by,John))|
0061 +-------------------------+------------------------------------------+
0062 ```
0063 
0064 ### Related Statements
0065 
0066 * [DESCRIBE DATABASE](sql-ref-syntax-aux-describe-database.html)