The data dictionary Professional
All SQL databases have a model that describes how data is organized in the database. For example, a Sales database may be comprised of tables like Customer, Order and Order-Details. Each table, in turn, consists of columns like Firstname or CustomerID. In addition, a table has specific attributes such as primary-keys or foreign-keys and columns have associated attributes like indexed or not.
This model, along with other information such as privileges, is stored in a set of system tables called the database's catalog, also known as the Data dictionary. We will use the term Dictionary for consistency.
A data dictionary contains data describing data, it is a meta data structure. Since all data describing a database is stored in system tables, all information about the data model can be obtained from a DBMS using SQL SELECT statements. Unfortunately, the names of system tables can differ between DBMS vendors. To overcome this problem, the ODBCDBE recognizes a predefined set of DBMS independent system-table names, so that an application developer gains transparent access to the data dictionary. The syntax for dictionary table names is as follows:
The @ sign indicates a meta data request. db. is the name of the database whose dictionary is accessed, table. stands for the name of the database table to retrieve meta data from and KEYWORD indicates the type of meta data. Note that data stored in the data dictionary is READ ONLY and cannot be changed by an Xbase++ application. The data dictionary can only be modified with a Database Administration Tool each DBMS is accompanied with.
Table name | Description of meta data |
---|---|
@SCHEMAS | All valid schemas for the data source |
@DATABASES | All valid databases for the data source |
@TABLETYPES | All valid table types for the data source |
@db.TABLES | All tables contained in the databases |
@db.VIEWS | All views defined in the database |
@db.PROCEDURES | All procedures defined for the database |
@db.table.COLUMNS | All columns per data source, database and table |
@db.table.PKEYS | All primary keys per data source, database and table |
@db.table.FKEYS | All foreign keys per data source, database and table |
The following code demonstrates how meta data can be inspected from an Xbase++ application. Assume a database named Sales containing a Customer table:
The resulting output of this code as it was obtained from MS SQL Server is shown below (slightly reformatted). It lists the structure of the COLUMNS table and displays data stored in the first record. This data defines the first column in the Customer table, i.e. the database field holding the customer number (FIELD->CUSTNO):
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.