pindare
pindare

Reputation: 2470

Get information about schema, tables, primary keys

How to get the name of the schema, tables and primary keys? How to know his authorizations? The only information I have is obtained by the command below:

db2 => connect

   Database Connection Information

 Database server        = DB2/AIX64 11.1.3.3
 SQL authorization ID   = mkrugger
 Local database alias   = DBRCF

Upvotes: 0

Views: 565

Answers (1)

mao
mao

Reputation: 12267

You can use the command line (interactive command line processor), if you want, but if you are starting out then it is easier to use a GUI tool.

Example free GUI, IBM Data Studio, and there are many more (any GUI that works with JDBC should work with Db2 on Linux/Unix/Windows). These are easy to find online and download if you are permitted.

To use the Db2 command-line (clp) which is what you show in your question, Example command lines:

list tables for all
list tables for user
list tables for schema ...
describe table ...
describe indexes for table ...

Reference for LIST TABLES command You can also use plain SQL to read the catalog views, which describes the schemas, tables, primary keys as a series of views.

Look in the online free documentation for details of views like SYSCAT.TABLES, SYSCAT.COLUMNS , SYSCAT.INDEXES and hundreds of other views.

Depending on which Db2 product is installed locally, there are a range of other command-line based tools. One in particular is db2look which lets you extract all of the DDL of the database (or a subset of it) into a plain text file if you prefer that.

Upvotes: 1

Related Questions