>

CREATE TABLE Statement

Description

Creates a new table.

Note

The Microsoft Jet database engine doesn't support the use of CREATE TABLE, or any of the data definition language (DDL) statements, with non-Jet database engine databases. Use the data access object Create methods instead.

Syntax

CREATE TABLE table (field1 type [(size)] [index1] [, field2 type [(size)]
ú[index2] [, ...]] [, multifieldindex [, ...]])

The CREATE TABLE statement has these parts.

Part

Description

table

The name of the table to be created.

field1, field2

The name of field or fields to be created in the new table. You must create at least one field.

type

The data type of field in the new table.

size

The field size in characters (Text and Binary fields only).

index1, index2

A CONSTRAINT clause defining a single-field index. See the CONSTRAINT clause topic for more information on how to create this index.

multifieldindex

A CONSTRAINT clause defining a multiple-field index. See the CONSTRAINT clause topic for more information on how to create this index.


Remarks

You can use the CREATE INDEX statement to create indexes on existing tables.

See Also

ALTER TABLE Statement, CONSTRAINT Clause, CREATE INDEX Statement, DROP Statement.

Example

This example creates a new table called ThisTable with two Text fields.


CREATE TABLE ThisTable (FirstName TEXT, LastName TEXT);
This example creates a new table called MyTable with two Text fields, a Date/Time field, and a unique index made up of all three fields.


CREATE TABLE MyTable (FirstName TEXT, LastName TEXT, DateOfBirth DATETIME,
CONSTRAINT MyTableConstraint UNIQUE (FirstName, LastName, DateOfBirth));
This example creates a new table with two Text fields and an Integer field. The SSN field is the primary key.


CREATE TABLE NewTable (FirstName TEXT, LastName TEXT, SSN INTEGER CONSTRAINT MyFieldConstraint PRIMARY KEY);