| Lesson 6 | Describing columns |
| Objective | Gather information about the columns in a table. |
A core part of managing database objects in Oracle is understanding the structure of each table—its columns, data types, nullability rules, storage characteristics, and statistical properties. Oracle stores this metadata in data dictionary views, which provide a consistent and authoritative way to look inside your schema or across the entire database.
In Oracle 23c/23ai, data dictionary access continues to follow the same core pattern used in earlier releases:
use USER_* views to inspect your own objects, ALL_* views to inspect objects you have privileges on,
and DBA_* views for full administrative visibility. For table columns specifically, the most important view is
USER_TAB_COLUMNS.
USER_TAB_COLUMNS provides a detailed description of each column in the tables you own. The following list summarizes the most frequently used metadata elements:
TABLE_NAME |
The name of the table, matching the TABLE_NAME column in USER_TABLES.
|
COLUMN_NAME |
The name of the column within the table. |
DATA_TYPE |
The Oracle data type, such as VARCHAR2, NUMBER, DATE, CLOB, BLOB, or BOOLEAN (23c). |
DATA_LENGTH |
Maximum length of the column’s data representation, depending on data type. |
CHAR_COL_DECL_LENGTH |
Declared character length for VARCHAR2, CHAR, and similar character columns. |
DATA_PRECISION / DATA_SCALE |
Precision and scale of numeric columns. |
NULLABLE |
Shows "N" if the column does not allow NULL values; otherwise "Y". |
These fields allow you to reconstruct the logical structure of your table using only the metadata provided by Oracle’s catalog. They are foundational for schema analysis, report generation, automated code generation, and data governance.
In addition to structural metadata, Oracle maintains column-level statistics in
USER_TAB_COL_STATISTICS.
These statistics are used by the Cost-Based Optimizer (CBO) to generate efficient execution plans.
Statistical metadata commonly includes:
Modern Oracle databases no longer use the old ANALYZE command for gathering statistics.
Instead, statistics are collected automatically or manually using DBMS_STATS.
This provides more accurate, efficient, and optimizer-friendly results.
When gathering information about multiple tables, you often need to combine table-level and column-level metadata.
The example below demonstrates joining USER_TABLES with USER_TAB_COLUMNS to list each table and its columns:
SELECT t.table_name,
c.column_name
FROM user_tables t
JOIN user_tab_columns c
ON t.table_name = c.table_name
ORDER BY t.table_name, c.column_id;
This returns all tables owned by your user along with their columns, ordered in the same sequence as they appear in the table definition.
Beyond the basic views, Oracle provides other useful metadata sources:
ALL_TAB_COLUMNS – includes columns in tables you have privileges on.DBA_TAB_COLUMNS – catalog-wide view for DBAs.DBA_TAB_COL_USAGE – indicates how columns are used in predicates and joins, useful for index tuning.USER_LOBS – for CLOB/BLOB/JSON and other LOB metadata.These views allow you to perform everything from schema documentation to impact analysis during development or migration.
TABLE_NAME |
Contains the name of the table. |
AVG_ROW_LENGTH |
A column in the USER_TABLES view. |
DATA_TYPE |
A column in the USER_TAB_COLUMNS view. |
ALL_TABLES |
Lists tables in schemas accessible to the current user. |
COLUMN_NAME |
The name of columns in USER_TAB_COLUMNS. |
USER_TABLES |
Lists the tables in the current user's schema. |
A high-quality relational design extends beyond tables and columns—it requires a consistent object naming strategy. Many large organizations maintain naming standards and an object name thesaurus to ensure consistency and clarity across applications.
Whether you work with government agencies, enterprise systems, or internal development teams, using predictable naming conventions reduces ambiguity, improves code readability, and ensures smooth collaboration.
If your organization does not provide naming standards, you should create guidelines that match the patterns shown throughout this module and apply them consistently.