4D v16

column_definition

Home

 
4D v16
column_definition

column_definition  


 

 

sql_name sql_data_type_name [(int_number)][NOT NULL [UNIQUE]] [AUTO_INCREMENT] [AUTO_GENERATE]

A column_definition contains the name (sql_name) and data type (sql_data_type_name) of a column. You can also pass an optional int_number as well as the NOT NULL, UNIQUE, AUTO_INCREMENT and/or AUTO_GENERATE keywords.

  • Passing NOT NULL in the column_definition means that the column will not accept null values.
  • Passing UNIQUE means that the same value may not be inserted into this column twice. Note that only NOT NULL columns can have the UNIQUE attribute. The UNIQUE keyword must always be preceded by NOT NULL.
  • Passing AUTO_INCREMENT means that the column will generate a unique number for each new row. This attribute can only be used with number columns.
  • Passing AUTO_GENERATE means that a UUID will be generated automatically in the column for each new row. This attribute can only be used with UUID columns. 

Each column must have a data type. The column should either be defined as "null" or "not null" and if this value is left blank, the database assumes "null" as the default. The data type for the column does not restrict what data may be put in that column.

Example  

Here is a simple example which creates a table with two columns (ID and Name):

CREATE TABLE ACTOR_FANS
(ID INT32, Name VARCHAR NOT NULL UNIQUE);



See also 

ALTER TABLE
CREATE TABLE
sql_data_type_name

 
PROPERTIES 

Product: 4D
Theme: Syntax rules

 
HISTORY 

 
ARTICLE USAGE

4D SQL Reference ( 4D v16)