Teradata Package for Python Function Reference on VantageCloud Lake - db_list_tables - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.
Teradata® Package for Python Function Reference on VantageCloud Lake
- Deployment
- VantageCloud
- Edition
- Lake
- Product
- Teradata Package for Python
- Release Number
- 20.00.00.03
- Published
- December 2024
- ft:locale
- en-US
- ft:lastEdition
- 2024-12-19
- dita:id
- TeradataPython_FxRef_Lake_2000
- Product Category
- Teradata Vantage
- teradataml.dbutils.dbutils.db_list_tables = db_list_tables(schema_name=None, object_name=None, object_type='all')
- DESCRIPTION:
Lists the Vantage objects(table/view) names for the specified schema name.
PARAMETERS:
schema_name:
Optional Argument.
Specifies the name of schema in the database. If schema is not specified, function lists tables/views from
the current database.
Default Value: None
Types: str
object_name:
Optional Argument.
Specifies a table/view name or pattern to be used for filtering them from the database.
Pattern may contain '%' or '_' as pattern matching characters.
A '%' represents any string of zero or more arbitrary characters. Any string of characters is acceptable as
a replacement for the percent.
A '_' represents exactly one arbitrary character. Any single character is acceptable in the position in
which the underscore character appears.
Note:
* If '%' is specified in 'object_name', then the '_' character is not evaluated for an arbitrary character.
Default Value: None
Types: str
Example:
1. '%abc' will return all table/view object names starting with any character and ending with abc.
2. 'a_c' will return all table/view object names starting with 'a', ending with 'c' and has length of 3.
object_type:
Optional Argument.
Specifies object type to apply the filter. Valid values for this argument are 'all','table','view',
'volatile','temp'.
* all - List all the object types.
* table - List only tables.
* view - List only views.
* volatile - List only volatile tables.
* temp - List all teradataml temporary objects created in the specified database.
Default Value: 'all'
Types: str
RETURNS:
Pandas DataFrame
RAISES:
TeradataMlException - If the object_type argument is provided with invalid values.
OperationalError - If any errors are raised from Vantage.
EXAMPLES:
# Example 1 - List all object types in the default schema
>>> load_example_data("dataframe", "admissions_train")
>>> db_list_tables()
# Example 2 - List all the views in the default schema
>>> execute_sql("create view temporary_view as (select 1 as dummy_col1, 2 as dummy_col2);")
>>> db_list_tables(None , None, 'view')
# Example 3 - List all the object types in the default schema whose names begin with 'abc' followed by any number
# of characters in the end.
>>> execute_sql("create view abcd123 as (select 1 as dummy_col1, 2 as dummy_col2);")
>>> db_list_tables(None, 'abc%', None)
# Example 4 - List all the tables in the default schema whose names begin with 'adm' followed by any number of
# characters and ends with 'train'.
>>> load_example_data("dataframe", "admissions_train")
>>> db_list_tables(None, 'adm%train', 'table')
# Example 5 - List all the views in the default schema whose names begin with any character but ends with 'abc'
>>> execute_sql("create view view_abc as (select 1 as dummy_col1, 2 as dummy_col2);")
>>> db_list_tables(None, '%abc', 'view')
# Example 6 - List all the volatile tables in the default schema whose names begin with 'abc' and ends with any
# arbitrary character and has a length of 4
>>> execute_sql("CREATE volatile TABLE abcd(col0 int, col1 float) NO PRIMARY INDEX;")
>>> db_list_tables(None, 'abc_', 'volatile')
# Example 7 - List all the temporary objects created by teradataml in the default schema whose names begins and
# ends with any number of arbitrary characters but contains 'filter' in between.
>>> db_list_tables(None, '%filter%', 'temp')