ZhangChaoming commented on a change in pull request #18386:
URL: https://github.com/apache/flink/pull/18386#discussion_r834916265
##########
File path: docs/content/docs/dev/table/sql/show.md
##########
@@ -504,10 +504,69 @@ Show current catalog.
## SHOW DATABASES
```sql
-SHOW DATABASES
+SHOW DATABASES [ ( FROM | IN ) catalog_name ] [ [NOT] LIKE regex_pattern ]
```
-Show all databases in the current catalog.
+Show all databases for an optionally specified catalog. If no catalog is
specified then the databases are returned from the current catalog.
Additionally, the output of this statement may be filtered by an optional
matching pattern.
+
+**LIKE**
+Show all databases with optional `LIKE` clause, whose name is whether similar
to the `<sql_like_pattern>`.
+
+The syntax of sql pattern in `LIKE` clause is the same as that of `MySQL`
dialect.
+* `%` matches any number of characters, even zero characters, `\%` matches one
`%` character.
+* `_` matches exactly one character, `\_` matches one `_` character.
+
+### SHOW DATABASES EXAMPLES
+
+Assumes that we have a catalog named `catalog1` (current catalog) which has
the following databases:
+* db_1
+* my_db_2
+
+- Shows all databases of the given catalog.
+
+```sql
+show databases from catalog1;
+-- show databases from catalog1;
+-- show databases in catalog1;
+-- show databases;
++------------+
+| table name |
++------------+
+| db_1 |
+| my_db_2 |
++------------+
+2 rows in set
+```
+
+- Shows all database of the given catalog, which are similar to the given sql
pattern.
+
+```sql
+show databases from catalog1 like 'my%';
+-- show databases from catalog1 like 'my%';
+-- show databases in catalog1 like 'my%';
+-- show databases like 'my%';
++------------+
+| table name |
++------------+
+| my_db_2 |
++------------+
+1 row in set
+```
+
+- Shows all databases of the given catalog, which are not similar to the given
sql pattern.
+
+```sql
+show databases from catalog1 like 'my%';
+-- show databases from catalog1 like 'my%';
+-- show databases in catalog1 like 'my%';
+-- show databases like 'my%';
++------------+
+| table name |
++------------+
+| db_1 |
++------------+
+1 row in set
+```
Review comment:
A smiple example.
```sql
show databases from catalog1 like 'my%';
-- show databases from catalog1 like 'my%';
-- show databases in catalog1 like 'my%';
-- show databases like 'my%';
-- show databases like '_y%';
+------------+
| table name |
+------------+
| my_db_2 |
+------------+
1 row in set
```
##########
File path:
flink-table/flink-sql-client/src/test/resources/sql/catalog_database.q
##########
@@ -106,6 +122,77 @@ show databases;
2 rows in set
!ok
+show databases in catalog1;
++---------------+
+| database name |
++---------------+
+| db1 |
+| db1_1 |
+| pre_db |
++---------------+
+3 rows in set
+!ok
+
+show databases from catalog1;
++---------------+
+| database name |
++---------------+
+| db1 |
+| db1_1 |
+| pre_db |
++---------------+
+3 rows in set
+!ok
+
+show databases from catalog1 like 'db1';
++---------------+
+| database name |
++---------------+
+| db1 |
++---------------+
+1 rows in set
+!ok
+
+show databases in catalog1 not like 'pre%';
++---------------+
+| database name |
++---------------+
+| db1 |
+| db1_1 |
++---------------+
+2 rows in set
+!ok
+
+show databases in catalog1 like '%db%';
++---------------+
+| database name |
++---------------+
+| db1 |
+| db1_1 |
+| pre_db |
++---------------+
+3 rows in set
+!ok
+
+show databases like 'db%';
++---------------+
+| database name |
++---------------+
+| db1 |
++---------------+
+1 rows in set
+!ok
+
+show databases in catalog1 like 'db%';
++---------------+
+| database name |
++---------------+
+| db1 |
+| db1_1 |
++---------------+
+2 rows in set
+!ok
+
Review comment:
same as mentioned above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]