pyflink.table.table_environment.TableEnvironment.use_database#
- TableEnvironment.use_database(database_name: str)[source]#
Sets the current default database. It has to exist in the current catalog. That path will be used as the default one when looking for unqualified object names.
This is used during the resolution of object paths. Both the catalog and database are optional when referencing catalog objects such as tables, views etc. The algorithm looks for requested objects in following paths in that order:
[current-catalog].[current-database].[requested-path]
[current-catalog].[requested-path]
[requested-path]
Example:
Given structure with default catalog set to
default_catalog
and default database set todefault_database
.root: |- default_catalog |- default_database |- tab1 |- db1 |- tab1 |- cat1 |- db1 |- tab1
The following table describes resolved paths:
Requested path
Resolved path
tab1
default_catalog.default_database.tab1
db1.tab1
default_catalog.db1.tab1
cat1.db1.tab1
cat1.db1.tab1
- Throws
CatalogException
thrown if the given catalog and database could not be set as the default ones.
See also
use_catalog()
- Parameters
database_name – The name of the database to set as the current database.