4D v14CREATE TABLE |
||||||||||||||
|
4D v14
CREATE TABLE
CREATE TABLE
The CREATE TABLE command is used to create a table named sql_name having the fields specified by passing one or more column_definition and/or table_constraint type arguments. If the IF NOT EXISTS constraint is passed, the table is only created when there is no table with the same name already in the database. Otherwise, it is not created and no error is generated. The first sql_name parameter (optional) can be used to designate the SQL schema to which you want to assign the table. If you do not pass this parameter or if you pass the name of a schema that does not exist, the table is automatically assigned to the default schema, named "DEFAULT_SCHEMA." For more information about SQL schemas, please refer to the Principles for integrating 4D and the 4D SQL engine section. Note: It is also possible to assign a table to an SQL schema using the "Schemas" pop-up menu found in the 4D table Inspector palette. This menu contains the list of schemas defined in the database. A column_definition contains the name (sql_name) and data type (sql_data_type_name) of a column and a table_constraint restricts the values that a table can store. The PRIMARY KEY keyword is used to specify the primary key when the table is created. For more information about primary keys, please refer to the Principles for integrating 4D and the 4D SQL engine section. The ENABLE REPLICATE and DISABLE REPLICATE keywords are used to enable or disable the mechanism allowing replication of the table (see the Replication via SQL section). Here is a simple example for creating a table with two columns: CREATE TABLE ACTOR_FANS This example creates the same table but only if there is no existing table with the same name: CREATE TABLE IF NOT EXISTS ACTOR_FANS This example creates a "Preferences" table and assigns it to the "Control" schema: CREATE TABLE Control.Preferences |
PROPERTIES
Product: 4D SEE ALSO
ALTER TABLE ARTICLE USAGE
4D SQL Reference ( 4D v14) Inherited from : CREATE TABLE ( 4D v11 SQL Release 4 ) |
||||||||||||