SHOW Statements

SHOW statements are used to list objects within their corresponding parent, such as catalogs, databases, tables and views, columns, functions, and modules. See the individual commands for more details and additional options.

SHOW CREATE statements are used to print a DDL statement with which a given object can be created. The currently ‘SHOW CREATE’ statement is only available in printing DDL statement of the given table and view.

Flink SQL supports the following SHOW statements for now:

  • SHOW CATALOGS
  • SHOW CURRENT CATALOG
  • SHOW DATABASES
  • SHOW CURRENT DATABASE
  • SHOW TABLES
  • SHOW CREATE TABLE
  • SHOW COLUMNS
  • SHOW VIEWS
  • SHOW CREATE VIEW
  • SHOW FUNCTIONS
  • SHOW MODULES
  • SHOW JARS

Run a SHOW statement

Java

SHOW statements can be executed with the executeSql() method of the TableEnvironment. The executeSql() method returns objects for a successful SHOW operation, otherwise will throw an exception.

The following examples show how to run a SHOW statement in TableEnvironment.

Scala

SHOW statements can be executed with the executeSql() method of the TableEnvironment. The executeSql() method returns objects for a successful SHOW operation, otherwise will throw an exception.

The following examples show how to run a SHOW statement in TableEnvironment.

Python

SHOW statements can be executed with the execute_sql() method of the TableEnvironment. The execute_sql() method returns objects for a successful SHOW operation, otherwise will throw an exception.

The following examples show how to run a SHOW statement in TableEnvironment.

SQL CLI

SHOW statements can be executed in SQL CLI.

The following examples show how to run a SHOW statement in SQL CLI.

Java

  1. StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
  2. StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
  3. // show catalogs
  4. tEnv.executeSql("SHOW CATALOGS").print();
  5. // +-----------------+
  6. // | catalog name |
  7. // +-----------------+
  8. // | default_catalog |
  9. // +-----------------+
  10. // show current catalog
  11. tEnv.executeSql("SHOW CURRENT CATALOG").print();
  12. // +----------------------+
  13. // | current catalog name |
  14. // +----------------------+
  15. // | default_catalog |
  16. // +----------------------+
  17. // show databases
  18. tEnv.executeSql("SHOW DATABASES").print();
  19. // +------------------+
  20. // | database name |
  21. // +------------------+
  22. // | default_database |
  23. // +------------------+
  24. // show current database
  25. tEnv.executeSql("SHOW CURRENT DATABASE").print();
  26. // +-----------------------+
  27. // | current database name |
  28. // +-----------------------+
  29. // | default_database |
  30. // +-----------------------+
  31. // create a table
  32. tEnv.executeSql("CREATE TABLE my_table (...) WITH (...)");
  33. // show tables
  34. tEnv.executeSql("SHOW TABLES").print();
  35. // +------------+
  36. // | table name |
  37. // +------------+
  38. // | my_table |
  39. // +------------+
  40. // show create table
  41. tEnv.executeSql("SHOW CREATE TABLE my_table").print();
  42. // CREATE TABLE `default_catalog`.`default_db`.`my_table` (
  43. // ...
  44. // ) WITH (
  45. // ...
  46. // )
  47. // show columns
  48. tEnv.executeSql("SHOW COLUMNS FROM my_table LIKE '%f%'").print();
  49. // +--------+-------+------+-----+--------+-----------+
  50. // | name | type | null | key | extras | watermark |
  51. // +--------+-------+------+-----+--------+-----------+
  52. // | field2 | BYTES | true | | | |
  53. // +--------+-------+------+-----+--------+-----------+
  54. // create a view
  55. tEnv.executeSql("CREATE VIEW my_view AS SELECT * FROM my_table");
  56. // show views
  57. tEnv.executeSql("SHOW VIEWS").print();
  58. // +-----------+
  59. // | view name |
  60. // +-----------+
  61. // | my_view |
  62. // +-----------+
  63. // show create view
  64. tEnv.executeSql("SHOW CREATE VIEW my_view").print();
  65. // CREATE VIEW `default_catalog`.`default_db`.`my_view`(`field1`, `field2`, ...) as
  66. // SELECT *
  67. // FROM `default_catalog`.`default_database`.`my_table`
  68. // show functions
  69. tEnv.executeSql("SHOW FUNCTIONS").print();
  70. // +---------------+
  71. // | function name |
  72. // +---------------+
  73. // | mod |
  74. // | sha256 |
  75. // | ... |
  76. // +---------------+
  77. // create a user defined function
  78. tEnv.executeSql("CREATE FUNCTION f1 AS ...");
  79. // show user defined functions
  80. tEnv.executeSql("SHOW USER FUNCTIONS").print();
  81. // +---------------+
  82. // | function name |
  83. // +---------------+
  84. // | f1 |
  85. // | ... |
  86. // +---------------+
  87. // show modules
  88. tEnv.executeSql("SHOW MODULES").print();
  89. // +-------------+
  90. // | module name |
  91. // +-------------+
  92. // | core |
  93. // +-------------+
  94. // show full modules
  95. tEnv.executeSql("SHOW FULL MODULES").print();
  96. // +-------------+-------+
  97. // | module name | used |
  98. // +-------------+-------+
  99. // | core | true |
  100. // | hive | false |
  101. // +-------------+-------+

Scala

  1. val env = StreamExecutionEnvironment.getExecutionEnvironment()
  2. val tEnv = StreamTableEnvironment.create(env)
  3. // show catalogs
  4. tEnv.executeSql("SHOW CATALOGS").print()
  5. // +-----------------+
  6. // | catalog name |
  7. // +-----------------+
  8. // | default_catalog |
  9. // +-----------------+
  10. // show databases
  11. tEnv.executeSql("SHOW DATABASES").print()
  12. // +------------------+
  13. // | database name |
  14. // +------------------+
  15. // | default_database |
  16. // +------------------+
  17. // create a table
  18. tEnv.executeSql("CREATE TABLE my_table (...) WITH (...)")
  19. // show tables
  20. tEnv.executeSql("SHOW TABLES").print()
  21. // +------------+
  22. // | table name |
  23. // +------------+
  24. // | my_table |
  25. // +------------+
  26. // show create table
  27. tEnv.executeSql("SHOW CREATE TABLE my_table").print()
  28. // CREATE TABLE `default_catalog`.`default_db`.`my_table` (
  29. // ...
  30. // ) WITH (
  31. // ...
  32. // )
  33. // show columns
  34. tEnv.executeSql("SHOW COLUMNS FROM my_table LIKE '%f%'").print()
  35. // +--------+-------+------+-----+--------+-----------+
  36. // | name | type | null | key | extras | watermark |
  37. // +--------+-------+------+-----+--------+-----------+
  38. // | field2 | BYTES | true | | | |
  39. // +--------+-------+------+-----+--------+-----------+
  40. // create a view
  41. tEnv.executeSql("CREATE VIEW my_view AS SELECT * FROM my_table")
  42. // show views
  43. tEnv.executeSql("SHOW VIEWS").print()
  44. // +-----------+
  45. // | view name |
  46. // +-----------+
  47. // | my_view |
  48. // +-----------+
  49. // show create view
  50. tEnv.executeSql("SHOW CREATE VIEW my_view").print();
  51. // CREATE VIEW `default_catalog`.`default_db`.`my_view`(`field1`, `field2`, ...) as
  52. // SELECT *
  53. // FROM `default_catalog`.`default_database`.`my_table`
  54. // show functions
  55. tEnv.executeSql("SHOW FUNCTIONS").print()
  56. // +---------------+
  57. // | function name |
  58. // +---------------+
  59. // | mod |
  60. // | sha256 |
  61. // | ... |
  62. // +---------------+
  63. // create a user defined function
  64. tEnv.executeSql("CREATE FUNCTION f1 AS ...")
  65. // show user defined functions
  66. tEnv.executeSql("SHOW USER FUNCTIONS").print()
  67. // +---------------+
  68. // | function name |
  69. // +---------------+
  70. // | f1 |
  71. // | ... |
  72. // +---------------+
  73. // show modules
  74. tEnv.executeSql("SHOW MODULES").print()
  75. // +-------------+
  76. // | module name |
  77. // +-------------+
  78. // | core |
  79. // +-------------+
  80. // show full modules
  81. tEnv.executeSql("SHOW FULL MODULES").print()
  82. // +-------------+-------+
  83. // | module name | used |
  84. // +-------------+-------+
  85. // | core | true |
  86. // | hive | false |
  87. // +-------------+-------+

Python

  1. table_env = StreamTableEnvironment.create(...)
  2. # show catalogs
  3. table_env.execute_sql("SHOW CATALOGS").print()
  4. # +-----------------+
  5. # | catalog name |
  6. # +-----------------+
  7. # | default_catalog |
  8. # +-----------------+
  9. # show databases
  10. table_env.execute_sql("SHOW DATABASES").print()
  11. # +------------------+
  12. # | database name |
  13. # +------------------+
  14. # | default_database |
  15. # +------------------+
  16. # create a table
  17. table_env.execute_sql("CREATE TABLE my_table (...) WITH (...)")
  18. # show tables
  19. table_env.execute_sql("SHOW TABLES").print()
  20. # +------------+
  21. # | table name |
  22. # +------------+
  23. # | my_table |
  24. # +------------+
  25. # show create table
  26. table_env.executeSql("SHOW CREATE TABLE my_table").print()
  27. # CREATE TABLE `default_catalog`.`default_db`.`my_table` (
  28. # ...
  29. # ) WITH (
  30. # ...
  31. # )
  32. # show columns
  33. table_env.execute_sql("SHOW COLUMNS FROM my_table LIKE '%f%'").print()
  34. # +--------+-------+------+-----+--------+-----------+
  35. # | name | type | null | key | extras | watermark |
  36. # +--------+-------+------+-----+--------+-----------+
  37. # | field2 | BYTES | true | | | |
  38. # +--------+-------+------+-----+--------+-----------+
  39. # create a view
  40. table_env.execute_sql("CREATE VIEW my_view AS SELECT * FROM my_table")
  41. # show views
  42. table_env.execute_sql("SHOW VIEWS").print()
  43. # +-----------+
  44. # | view name |
  45. # +-----------+
  46. # | my_view |
  47. # +-----------+
  48. # show create view
  49. table_env.execute_sql("SHOW CREATE VIEW my_view").print()
  50. # CREATE VIEW `default_catalog`.`default_db`.`my_view`(`field1`, `field2`, ...) as
  51. # SELECT *
  52. # FROM `default_catalog`.`default_database`.`my_table`
  53. # show functions
  54. table_env.execute_sql("SHOW FUNCTIONS").print()
  55. # +---------------+
  56. # | function name |
  57. # +---------------+
  58. # | mod |
  59. # | sha256 |
  60. # | ... |
  61. # +---------------+
  62. # create a user defined function
  63. table_env.execute_sql("CREATE FUNCTION f1 AS ...")
  64. # show user defined functions
  65. table_env.execute_sql("SHOW USER FUNCTIONS").print()
  66. # +---------------+
  67. # | function name |
  68. # +---------------+
  69. # | f1 |
  70. # | ... |
  71. # +---------------+
  72. # show modules
  73. table_env.execute_sql("SHOW MODULES").print()
  74. # +-------------+
  75. # | module name |
  76. # +-------------+
  77. # | core |
  78. # +-------------+
  79. # show full modules
  80. table_env.execute_sql("SHOW FULL MODULES").print()
  81. # +-------------+-------+
  82. # | module name | used |
  83. # +-------------+-------+
  84. # | core | true |
  85. # | hive | false |
  86. # +-------------+-------+

SQL CLI

  1. Flink SQL> SHOW CATALOGS;
  2. default_catalog
  3. Flink SQL> SHOW DATABASES;
  4. default_database
  5. Flink SQL> CREATE TABLE my_table (...) WITH (...);
  6. [INFO] Table has been created.
  7. Flink SQL> SHOW TABLES;
  8. my_table
  9. Flink SQL> SHOW CREATE TABLE my_table;
  10. CREATE TABLE `default_catalog`.`default_db`.`my_table` (
  11. ...
  12. ) WITH (
  13. ...
  14. )
  15. Flink SQL> SHOW COLUMNS from MyUserTable LIKE '%f%';
  16. +--------+-------+------+-----+--------+-----------+
  17. | name | type | null | key | extras | watermark |
  18. +--------+-------+------+-----+--------+-----------+
  19. | field2 | BYTES | true | | | |
  20. +--------+-------+------+-----+--------+-----------+
  21. 1 row in set
  22. Flink SQL> CREATE VIEW my_view AS SELECT * from my_table;
  23. [INFO] View has been created.
  24. Flink SQL> SHOW VIEWS;
  25. my_view
  26. Flink SQL> SHOW CREATE VIEW my_view;
  27. CREATE VIEW `default_catalog`.`default_db`.`my_view`(`field1`, `field2`, ...) as
  28. SELECT *
  29. FROM `default_catalog`.`default_database`.`my_table`
  30. Flink SQL> SHOW FUNCTIONS;
  31. mod
  32. sha256
  33. ...
  34. Flink SQL> CREATE FUNCTION f1 AS ...;
  35. [INFO] Function has been created.
  36. Flink SQL> SHOW USER FUNCTIONS;
  37. f1
  38. ...
  39. Flink SQL> SHOW MODULES;
  40. +-------------+
  41. | module name |
  42. +-------------+
  43. | core |
  44. +-------------+
  45. 1 row in set
  46. Flink SQL> SHOW FULL MODULES;
  47. +-------------+------+
  48. | module name | used |
  49. +-------------+------+
  50. | core | true |
  51. +-------------+------+
  52. 1 row in set
  53. Flink SQL> SHOW JARS;
  54. /path/to/addedJar.jar

Back to top

SHOW CATALOGS

  1. SHOW CATALOGS

Show all catalogs.

SHOW CURRENT CATALOG

  1. SHOW CURRENT CATALOG

Show current catalog.

SHOW DATABASES

  1. SHOW DATABASES

Show all databases in the current catalog.

SHOW CURRENT DATABASE

  1. SHOW CURRENT DATABASE

Show current database.

SHOW TABLES

  1. SHOW TABLES [ ( FROM | IN ) [catalog_name.]database_name ] [ [NOT] LIKE <sql_like_pattern> ]

Show all tables for an optionally specified database. If no database is specified then the tables are returned from the current database. Additionally, the output of this statement may be filtered by an optional matching pattern.

LIKE Show all tables with given table name and 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 TABLES EXAMPLES

Assumes that the db1 database located in catalog1 catalog has the following tables:

  • person
  • dim

the current database in session has the following tables:

  • fights
  • orders

  • Shows all tables of the given database.

  1. show tables from db1;
  2. -- show tables from catalog1.db1;
  3. -- show tables in db1;
  4. -- show tables in catalog1.db1;
  5. +------------+
  6. | table name |
  7. +------------+
  8. | dim |
  9. | person |
  10. +------------+
  11. 2 rows in set
  • Shows all tables of the given database, which are similar to the given sql pattern.
  1. show tables from db1 like '%n';
  2. -- show tables from catalog1.db1 like '%n';
  3. -- show tables in db1 like '%n';
  4. -- show tables in catalog1.db1 like '%n';
  5. +------------+
  6. | table name |
  7. +------------+
  8. | person |
  9. +------------+
  10. 1 row in set
  • Shows all tables of the given database, which are not similar to the given sql pattern.
  1. show tables from db1 not like '%n';
  2. -- show tables from catalog1.db1 not like '%n';
  3. -- show tables in db1 not like '%n';
  4. -- show tables in catalog1.db1 not like '%n';
  5. +------------+
  6. | table name |
  7. +------------+
  8. | dim |
  9. +------------+
  10. 1 row in set
  • Shows all tables of the current database.
  1. show tables;
  2. +------------+
  3. | table name |
  4. +------------+
  5. | items |
  6. | orders |
  7. +------------+
  8. 2 rows in set

SHOW CREATE TABLE

  1. SHOW CREATE TABLE

Show create table statement for specified table.

Attention Currently SHOW CREATE TABLE only supports table that is created by Flink SQL DDL.

SHOW COLUMNS

  1. SHOW COLUMNS ( FROM | IN ) [[catalog_name.]database.]<table_name> [ [NOT] LIKE <sql_like_pattern>]

Show all columns of the table with given table name and optional like clause.

LIKE Show all columns of the table with given table name and 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.

SHOW COLUMNS EXAMPLES

Assumes that the table named orders in the database1 database which is located in the catalog1 catalog has the following structure:

  1. +---------+-----------------------------+-------+-----------+---------------+----------------------------+
  2. | name | type | null | key | extras | watermark |
  3. +---------+-----------------------------+-------+-----------+---------------+----------------------------+
  4. | user | BIGINT | false | PRI(user) | | |
  5. | product | VARCHAR(32) | true | | | |
  6. | amount | INT | true | | | |
  7. | ts | TIMESTAMP(3) *ROWTIME* | true | | | `ts` - INTERVAL '1' SECOND |
  8. | ptime | TIMESTAMP_LTZ(3) *PROCTIME* | false | | AS PROCTIME() | |
  9. +---------+-----------------------------+-------+-----------+---------------+----------------------------+
  • Shows all columns of the given table.
  1. show columns from orders;
  2. -- show columns from database1.orders;
  3. -- show columns from catalog1.database1.orders;
  4. -- show columns in orders;
  5. -- show columns in database1.orders;
  6. -- show columns in catalog1.database1.orders;
  7. +---------+-----------------------------+-------+-----------+---------------+----------------------------+
  8. | name | type | null | key | extras | watermark |
  9. +---------+-----------------------------+-------+-----------+---------------+----------------------------+
  10. | user | BIGINT | false | PRI(user) | | |
  11. | product | VARCHAR(32) | true | | | |
  12. | amount | INT | true | | | |
  13. | ts | TIMESTAMP(3) *ROWTIME* | true | | | `ts` - INTERVAL '1' SECOND |
  14. | ptime | TIMESTAMP_LTZ(3) *PROCTIME* | false | | AS PROCTIME() | |
  15. +---------+-----------------------------+-------+-----------+---------------+----------------------------+
  16. 5 rows in set
  • Shows all columns of the given table, which are similar to the given sql pattern.
  1. show columns from orders like '%r';
  2. -- show columns from database1.orders like '%r';
  3. -- show columns from catalog1.database1.orders like '%r';
  4. -- show columns in orders like '%r';
  5. -- show columns in database1.orders like '%r';
  6. -- show columns in catalog1.database1.orders like '%r';
  7. +------+--------+-------+-----------+--------+-----------+
  8. | name | type | null | key | extras | watermark |
  9. +------+--------+-------+-----------+--------+-----------+
  10. | user | BIGINT | false | PRI(user) | | |
  11. +------+--------+-------+-----------+--------+-----------+
  12. 1 row in set
  • Shows all columns of the given table, which are not similar to the given sql pattern.
  1. show columns from orders not like '%_r';
  2. -- show columns from database1.orders not like '%_r';
  3. -- show columns from catalog1.database1.orders not like '%_r';
  4. -- show columns in orders not like '%_r';
  5. -- show columns in database1.orders not like '%_r';
  6. -- show columns in catalog1.database1.orders not like '%_r';
  7. +---------+-----------------------------+-------+-----+---------------+----------------------------+
  8. | name | type | null | key | extras | watermark |
  9. +---------+-----------------------------+-------+-----+---------------+----------------------------+
  10. | product | VARCHAR(32) | true | | | |
  11. | amount | INT | true | | | |
  12. | ts | TIMESTAMP(3) *ROWTIME* | true | | | `ts` - INTERVAL '1' SECOND |
  13. | ptime | TIMESTAMP_LTZ(3) *PROCTIME* | false | | AS PROCTIME() | |
  14. +---------+-----------------------------+-------+-----+---------------+----------------------------+
  15. 4 rows in set

SHOW VIEWS

  1. SHOW VIEWS

Show all views in the current catalog and the current database.

SHOW CREATE VIEW

  1. SHOW CREATE VIEW [catalog_name.][db_name.]view_name

Show create view statement for specified view.

SHOW FUNCTIONS

  1. SHOW [USER] FUNCTIONS

Show all functions including system functions and user-defined functions in the current catalog and current database.

USER Show only user-defined functions in the current catalog and current database.

SHOW MODULES

  1. SHOW [FULL] MODULES

Show all enabled module names with resolution order.

FULL Show all loaded modules and enabled status with resolution order.

SHOW JARS

  1. SHOW JARS

Show all added jars in the session classloader which are added by ADD JAR statements.

Attention Currently SHOW JARS only works in the SQL CLI.

Back to top