Back to home page

OSCL-LXR

 
 

    


0001 ---
0002 layout: global
0003 title: DROP DATABASE
0004 displayTitle: DROP 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 Drop a database and delete the directory associated with the database from the file system. An 
0025 exception will be thrown if the database does not exist in the system. 
0026 
0027 ### Syntax
0028 
0029 ```sql
0030 DROP { DATABASE | SCHEMA } [ IF EXISTS ] dbname [ RESTRICT | CASCADE ]
0031 ```
0032 
0033 ### Parameters
0034 
0035 * **DATABASE `|` SCHEMA**
0036 
0037     `DATABASE` and `SCHEMA` mean the same thing, either of them can be used.
0038 
0039 * **IF EXISTS**
0040 
0041     If specified, no exception is thrown when the database does not exist.
0042 
0043 * **RESTRICT**
0044 
0045     If specified, will restrict dropping a non-empty database and is enabled by default.
0046 
0047 * **CASCADE**
0048 
0049     If specified, will drop all the associated tables and functions.
0050 
0051 ### Examples
0052 
0053 ```sql
0054 -- Create `inventory_db` Database
0055 CREATE DATABASE inventory_db COMMENT 'This database is used to maintain Inventory';
0056 
0057 -- Drop the database and it's tables
0058 DROP DATABASE inventory_db CASCADE;
0059 
0060 -- Drop the database using IF EXISTS
0061 DROP DATABASE IF EXISTS inventory_db CASCADE;
0062 ```
0063 
0064 ### Related Statements
0065 
0066 * [CREATE DATABASE](sql-ref-syntax-ddl-create-database.html)
0067 * [DESCRIBE DATABASE](sql-ref-syntax-aux-describe-database.html)
0068 * [SHOW DATABASES](sql-ref-syntax-aux-show-databases.html)