Creates a new table.
Syntax
CREATE TABLE table (column type [(size)] [DEFAULT default]
[, column type [(size)] ...])
The CREATE TABLE statement has these parts:
|
Part |
Description |
|
table |
The name of the table to be created. |
|
column |
The name of the column or columns to be created in the new table. We must create at least one column. |
|
type |
The data type of the column in the new table. |
|
size |
The column size in characters or bytes for text or binary columns. |
|
default |
The expression defining the default value of column in the new table. Can contain literal values, and functions of these values. |
Remarks
Use the CREATE TABLE statement to define a new table and its columns. All text columns are created as Unicode text type columns.
The CREATE TABLE statement is an action query and cannot be used from within the ODBC driver.
To define a new drawing, use the CREATE DRAWING statement.
Examples
This example creates a new table called "This Table" with two text columns.
CREATE TABLE [This Table] ([First Name] TEXT, [Last Name] TEXT);
This example creates a new table called "My Table" with two text columns and a date/time column.
CREATE TABLE [My Table] ([First Name] TEXT, [Last Name] TEXT, [Birth Date] DATETIME);
This example creates a new table with two text columns of specified length (20 and 40 characters respectively) and an integer column with a default value of -1.
CREATE TABLE [New Table] ([First Name] TEXT(20), [Last Name] TEXT(40), [SSN] INTEGER DEFAULT -1);
This example creates a new table called "Orders" with a text column, an integer column with a default value of 1, and a date/time column with a default value equal to the 20th of September 2003:
CREATE TABLE [Orders] ([Product] TEXT, [Quantity] INTEGER DEFAULT 1, [Date] DATETIME DEFAULT #20/09/2003#);