Back to home page

OSCL-LXR

 
 

    


0001 ---
0002 layout: global
0003 title: SHOW DATABASES
0004 displayTitle: SHOW DATABASES
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 Lists the databases that match an optionally supplied regular expression pattern. If no
0025 pattern is supplied then the command lists all the databases in the system.
0026 Please note that the usage of `SCHEMAS` and `DATABASES` are interchangeable
0027 and mean the same thing.
0028 
0029 ### Syntax
0030 
0031 ```sql
0032 SHOW { DATABASES | SCHEMAS } [ LIKE regex_pattern ]
0033 ```
0034 
0035 ### Parameters
0036 
0037 * **regex_pattern**
0038 
0039     Specifies a regular expression pattern that is used to filter the results of the
0040     statement.
0041     * Except for `*` and `|` character, the pattern works like a regular expression.
0042     * `*` alone matches 0 or more characters and `|` is used to separate multiple different regular expressions,
0043        any of which can match.
0044     * The leading and trailing blanks are trimmed in the input pattern before processing. The pattern match is case-insensitive.
0045 
0046 ### Examples
0047 
0048 ```sql
0049 -- Create database. Assumes a database named `default` already exists in
0050 -- the system. 
0051 CREATE DATABASE payroll_db;
0052 CREATE DATABASE payments_db;
0053 
0054 -- Lists all the databases. 
0055 SHOW DATABASES;
0056 +------------+
0057 |databaseName|
0058 +------------+
0059 |     default|
0060 | payments_db|
0061 |  payroll_db|
0062 +------------+
0063   
0064 -- Lists databases with name starting with string pattern `pay`
0065 SHOW DATABASES LIKE 'pay*';
0066 +------------+
0067 |databaseName|
0068 +------------+
0069 | payments_db|
0070 |  payroll_db|
0071 +------------+
0072   
0073 -- Lists all databases. Keywords SCHEMAS and DATABASES are interchangeable. 
0074 SHOW SCHEMAS;
0075 +------------+
0076 |databaseName|
0077 +------------+
0078 |     default|
0079 | payments_db|
0080 |  payroll_db|
0081 +------------+
0082 ```
0083 
0084 ### Related Statements
0085 
0086 * [DESCRIBE DATABASE](sql-ref-syntax-aux-describe-database.html)
0087 * [CREATE DATABASE](sql-ref-syntax-ddl-create-database.html)
0088 * [ALTER DATABASE](sql-ref-syntax-ddl-alter-database.html)