Define columns with their data types, precision, scale, and constraints during table creation. Column definitions include the column name, data type, size specifications, and optional constraints like NOT NULL.
CREATE TABLE table_column
(
pkid NUMBER(1,0) NOT NULL
, code VARCHAR2(2) NOT NULL
);
Verify column creation by querying the data dictionary view
USER_TAB_COLUMNS
, which contains metadata about all columns in your schema:
SELECT table_name, column_name, data_type, data_length, data_precision, data_scale, nullable
FROM user_tab_columns
WHERE upper(table_name) = 'TABLE_COLUMN';
Query result:
| TABLE_NAME | COLUMN_NAME | DATA_TYPE | DATA_LENGTH | DATA_PRECISION | DATA_SCALE | NULLABLE |
+--------------+-------------+-----------+-------------+----------------+------------+----------+
| TABLE_COLUMN | PKID | NUMBER | 22 | 1 | 0 | N |
| TABLE_COLUMN | CODE | VARCHAR2 | 2 | | | N |
Note: DATA_LENGTH shows the internal storage size (22 bytes for NUMBER), while DATA_PRECISION and DATA_SCALE show the defined numeric precision and scale.