Teradata Package for Python Function Reference - 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

Product
Teradata Package for Python
Release Number
17.00
Published
November 2021
Language
English (United States)
Last Update
2021-11-19
lifecycle
previous
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.
        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
    >>> connection_object.execute("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 the default schema whose names begin with 'abc' followed by one
    # arbitrary character and any number of characters in the end.
    >>> connection_object.execute("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 one
    # arbitrary character and any number of characters in the end.
    >>> load_example_data("dataframe", "admissions_train")
    >>> db_list_tables(None, 'adm_%', 'table')
 
    # Example 5 - List all the views in the default schema whose names begin with any character but ends with 'abc'
    >>> connection_object.execute("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
    >>> connection_object.execute("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')