Show All Databases
Function
Shows all databases under the current project. The LIKE clause can be used to filter database names by regular expression pattern. If no pattern is provided, all databases in the system are listed.
Syntax
1 | SHOW [DATABASES | SCHEMAS] [LIKE regex_expression]; |
Keywords
- LIKE: Filter results using a regular expression pattern.
- DATABASES/SCHEMAS: Both are equivalent and can be used.
Parameters
| Parameter | Description |
|---|---|
| regex_expression | A regular expression used to filter results. Except for * and |, the pattern works the same as a regular expression. * can be used to match zero or more characters, and | is used to separate multiple different regular expressions. Pattern matching is case-insensitive. |
Precautions
DATABASES and SCHEMAS are equivalent and both return all database names.
Example 1: List All Databases
View all databases in the current instance.
SHOW DATABASES;
| databaseName |
|---|
| default |
| payments_db |
| payroll_db |
Example 2: Filter Databases by Pattern
View all database names starting with pay.
SHOW DATABASES LIKE 'pay*';
| databaseName |
|---|
| payments_db |
| payroll_db |
Example 3: Use the SCHEMAS Keyword
SCHEMAS is equivalent to DATABASES and can be used interchangeably.
SHOW SCHEMAS;
Example 4: Filter Using Multiple Patterns
View databases starting with pay or hr.
SHOW DATABASES LIKE 'pay*|hr*';
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot