How to List DB2 Schema Table Names

To see all table names under a specific schema in a DB2 database, you can use the following SQL query:

SELECT TABNAME FROM SYSCAT.TABLES WHERE TABSCHEMA = '<schema_name>';

Replace with the name of the schema you want to view table names for. This query will return the names of all tables in that schema.

Please be advised that executing this query requires sufficient permissions to access DB2 system catalog tables. If you do not have enough permissions, you may not be able to execute the query or may only be able to view partial results.

Additionally, you can use the DB2 command line utility db2look to obtain detailed definitions of database objects, including table names, column names, and other object definitions. The usage is as follows:

db2look -d <database_name> -e -o <output_file>

Replace with the name of the database you want to export, and with the path and name of the output file. This will generate a script file containing the definitions of database objects, including table names under the specified schema.

bannerAds