Defining Columns - Advanced SQL Engine - Teradata Database

SQL Fundamentals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
zwv1557098532464.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1141
lifecycle
previous
Product Category
Teradata Vantageâ„¢

The column definition clause of the CREATE TABLE statement defines the table column elements.

A name and a data type must be specified for each column defined for a table.

Here is an example that creates a table called employee with three columns:

   CREATE TABLE employee
     (deptno INTEGER
     ,name CHARACTER(23)
     ,hiredate DATE);

Each column can be further defined with one or more optional attribute definitions. The following attributes are also elements of the SQL column definition clause:

  • Data type attribute declaration, such as NOT NULL, FORMAT, TITLE, and CHARACTER SET
  • COMPRESS column storage attributes clause
  • DEFAULT and WITH DEFAULT default value control clauses
  • PRIMARY KEY, UNIQUE, REFERENCES, and CHECK column constraint attributes clauses

Here is an example that defines attributes for the columns in the employee table:

   CREATE TABLE employee
     (deptno INTEGER NOT NULL
     ,name CHARACTER(23) CHARACTER SET LATIN
     ,hiredate DATE DEFAULT CURRENT_DATE);