Create a table

A table can be visualized as a two-dimensional arrangement of data consisting of rows and columns.

The row is the horizontal part containing one or more columns. The column is the vertical part containing one or more rows of data of one data type. All data for a column must be of the same type. A table in SQL is a keyed or non-keyed physical file.

Tables are created using the CREATE TABLE statement. The definition must include its name and the names and attributes of its columns. The definition may include other attributes of the table such as primary key.

Example: Given that you have administrative authority, create a table named 'INVENTORY' with the following columns:

The primary key is PARTNO.

CREATE TABLE INVENTORY
                 (PARTNO         SMALLINT     NOT NULL,
                  DESCR          VARCHAR(24 ),
                  QONHAND        INT,
                  PRIMARY KEY(PARTNO))
Related information
Data types