db_list_tables() | Database Utilities | Teradata Package for Python - db_list_tables() - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Teradata Package for Python
Release Number
20.00
Published
March 2025
ft:locale
en-US
ft:lastEdition
2025-12-05
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
Product Category
Teradata Vantage

Use the db_list_tables() function to list tables and views from a specified schema.

Optional Arguments

schema_name
Specifies the name of the schema in the database. If the schema is not specified, the function lists tables and views from the current database. Default value is None.
object_name
Specifies a table or 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 replacement for the percent sign.
  • A '_' represents exactly one arbitrary character. Any single character is acceptable in the position in which the underscore character appears.
If '%' is specified in 'object_name', then the '_' character is not evaluated for an arbitrary character.
Example:
  • '%abc' will return all table and view object names starting with any character and ending with 'abc'.
  • 'a_c' will return all table and view object names starting with 'a', ending with 'c' and has length of 3.
Object_type
Specifies object type to apply the filter. Valid value includes:
  • all: list all the object types, which is the default value
  • 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 is all.

Example 1: List all the objects 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 objects in the default schema with specific conditions

This example lists all the objects in 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 with specific conditions

This example lists 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 with specific conditions

This example lists all the views in the default schema whose names begin with any character but end 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 with specific conditions

This example lists 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 with specific conditions

This example lists all the temporary objects created by teradataml in the default schema whose names begin and end with any number of arbitrary characters but contains 'filter' in between.

>>> db_list_tables(None, '%filter%', 'temp')