show all tables in DB2 using the LIST command

后端 未结 6 663
天涯浪人
天涯浪人 2021-01-31 09:26

This is embarrassing, but I can\'t seem to find a way to list the names of the tables in our DB2 database. Here is what I tried:

root@VO11555:~# su - db2inst1
ro         


        
6条回答
  •  不知归路
    2021-01-31 10:28

    To get a list of tables for the current database in DB2 -->

    Connect to the database:

    db2 connect to DATABASENAME user USER using PASSWORD
    

    Run this query:

    db2 LIST TABLES
    

    This is the equivalent of SHOW TABLES in MySQL.

    You may need to execute 'set schema myschema' to the correct schema before you run the list tables command. By default upon login your schema is the same as your username - which often won't contain any tables. You can use 'values current schema' to check what schema you're currently set to.

提交回复
热议问题