Catalog functions example

You can write an application that uses catalog functions to obtain information. For example, you can obtain a list of all tables that have a specified schema name.

The following output shows the information:
  • A list of all tables for the specified schema (qualifier) name or search pattern
  • Column, special column, foreign key, and statistics information for a selected table
Figure 1. Sample output from an application that uses catalog functions
Enter Search Pattern for Table Schema Name:
STUDENT
Enter Search Pattern for Table Name:
%
### TABLE SCHEMA              TABLE_NAME                TABLE_TYPE
    ------------------------- ------------------------- ----------

1   STUDENT                   CUSTOMER                  TABLE
2   STUDENT                   DEPARTMENT                TABLE
3   STUDENT                   EMP_ACT                   TABLE
4   STUDENT                   EMP_PHOTO                 TABLE
5   STUDENT                   EMP_RESUME                TABLE
6   STUDENT                   EMPLOYEE                  TABLE
7   STUDENT                   NAMEID                    TABLE
8   STUDENT                   ORD_CUST                  TABLE
9   STUDENT                   ORD_LINE                  TABLE
10  STUDENT                   ORG                       TABLE
11  STUDENT                   PROD_PARTS                TABLE
12  STUDENT                   PRODUCT                   TABLE
13  STUDENT                   PROJECT                   TABLE
14  STUDENT                   STAFF                     TABLE
Enter a table Number and an action:(n [Q | C | P | I | F | T |O | L])
|Q=Quit     C=cols     P=Primary Key I=Index   F=Foreign Key |
|T=Tab Priv O=Col Priv S=Stats       L=List Tables           |
1c
Schema: STUDENT  Table Name: CUSTOMER
   CUST_NUM, NOT NULLABLE, INTeger (10)
   FIRST_NAME, NOT NULLABLE, CHARacter (30)
   LAST_NAME, NOT NULLABLE, CHARacter (30)
   STREET, NULLABLE, CHARacter (128)
   CITY, NULLABLE, CHARacter (30)
   PROV_STATE, NULLABLE, CHARacter (30)
   PZ_CODE, NULLABLE, CHARacter (9)
   COUNTRY, NULLABLE, CHARacter (30)
   PHONE_NUM, NULLABLE, CHARacter (20)
>> Hit Enter to Continue<<
1p
Primary Keys for STUDENT.CUSTOMER
 1  Column: CUST_NUM            Primary Key Name: = NULL
>> Hit Enter to Continue<<
1f
Primary Key and Foreign Keys for STUDENT.CUSTOMER
  CUST_NUM  STUDENT.ORD_CUST.CUST_NUM
      Update Rule SET NULL , Delete Rule: NO ACTION
>> Hit Enter to Continue<<