INFORMATION_SCHEMA and Oracle |
||
The information schema (INFORMATION_SCHEMA) is a standard representation of metadata in SQL. Historically, each developer of relational DBMS provided system tables that contained meta-information in particular names of tables, columns, data types, constraints, etc. Structure of system tables can be changed between versions of the product. However, the support of the information schema makes it possible to change the structure of system tables without changing the access to metadata. Another advantage of using INFORMATION_SCHEMA is that requests for metadata do not depend on the DBMS used. Among the lead manufacturers, perhaps, only Oracle does not support INFORMATION_SCHEMA. To be fair, it should be said that Oracle provides the ability to use system views instead of directly accessing system tables, which also allows them to safely change the structure of system tables. Here are some typical queries given in the standard style and for Oracle. 1. List of database tables (for current DB)Standard Oracle
2. List of columns of the specified table (for example, PC)Standard
Oracle
3. Data type and data size of the specified character column of the table (the model column of PC table)Standard
Oracle
4. The name of the primary key constraint of PC tableStandard
Oracle
5. List of columns that make up the primary key of the Utb table (composite key)Standard
Here, in the outer query, we get the columns which are mentioned in the constraints. After that we choose those of them that have constraint name matching the name of primary key constraint for the same table. In principle, condition table_name = 'utb' of the main query is redundant for getting the correct answer, because the constraint name is unique for the entire database. However, early filtering significantly speeds up the execution of the query. Oracle
|