SHOW Statements

SHOW statements are used to list all catalogs, or list all databases in the current catalog, or list all tables/views in the current catalog and the current database, or show current catalog and database, or list all functions including temp system functions, system functions, temp catalog functions and catalog functions in the current catalog and the current database.

Flink SQL supports the following SHOW statements for now:

  • SHOW CATALOGS
  • SHOW CURRENT CATALOG
  • SHOW DATABASES
  • SHOW CURRENT DATABASE
  • SHOW TABLES
  • SHOW VIEWS
  • SHOW FUNCTIONS

Run a SHOW statement

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.

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.

SHOW statements can be executed in SQL CLI.

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

  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. // create a view
  41. tEnv.executeSql("CREATE VIEW my_view AS ...");
  42. // show views
  43. tEnv.executeSql("SHOW VIEWS").print();
  44. // +-----------+
  45. // | view name |
  46. // +-----------+
  47. // | my_view |
  48. // +-----------+
  49. // show functions
  50. tEnv.executeSql("SHOW FUNCTIONS").print();
  51. // +---------------+
  52. // | function name |
  53. // +---------------+
  54. // | mod |
  55. // | sha256 |
  56. // | ... |
  57. // +---------------+
  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. // create a view
  27. tEnv.executeSql("CREATE VIEW my_view AS ...")
  28. // show views
  29. tEnv.executeSql("SHOW VIEWS").print()
  30. // +-----------+
  31. // | view name |
  32. // +-----------+
  33. // | my_view |
  34. // +-----------+
  35. // show functions
  36. tEnv.executeSql("SHOW FUNCTIONS").print()
  37. // +---------------+
  38. // | function name |
  39. // +---------------+
  40. // | mod |
  41. // | sha256 |
  42. // | ... |
  43. // +---------------+
  1. settings = EnvironmentSettings.new_instance()...
  2. table_env = StreamTableEnvironment.create(env, settings)
  3. # show catalogs
  4. table_env.execute_sql("SHOW CATALOGS").print()
  5. # +-----------------+
  6. # | catalog name |
  7. # +-----------------+
  8. # | default_catalog |
  9. # +-----------------+
  10. # show databases
  11. table_env.execute_sql("SHOW DATABASES").print()
  12. # +------------------+
  13. # | database name |
  14. # +------------------+
  15. # | default_database |
  16. # +------------------+
  17. # create a table
  18. table_env.execute_sql("CREATE TABLE my_table (...) WITH (...)")
  19. # show tables
  20. table_env.execute_sql("SHOW TABLES").print()
  21. # +------------+
  22. # | table name |
  23. # +------------+
  24. # | my_table |
  25. # +------------+
  26. # create a view
  27. table_env.execute_sql("CREATE VIEW my_view AS ...")
  28. # show views
  29. table_env.execute_sql("SHOW VIEWS").print()
  30. # +-----------+
  31. # | view name |
  32. # +-----------+
  33. # | my_view |
  34. # +-----------+
  35. # show functions
  36. table_env.execute_sql("SHOW FUNCTIONS").print()
  37. # +---------------+
  38. # | function name |
  39. # +---------------+
  40. # | mod |
  41. # | sha256 |
  42. # | ... |
  43. # +---------------+
  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> CREATE VIEW my_view AS ...;
  10. [INFO] View has been created.
  11. Flink SQL> SHOW VIEWS;
  12. my_view
  13. Flink SQL> SHOW FUNCTIONS;
  14. mod
  15. sha256
  16. ...

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

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

SHOW VIEWS

  1. SHOW VIEWS

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

SHOW FUNCTIONS

  1. SHOW FUNCTIONS

Show all functions including temp system functions, system functions, temp catalog functions and catalog functions in the current catalog and current database.