The CREATE TABLE statement is used to create a new table and its fields.
CREATE TABLE Names (Name TEXT);
The command(s) completed successfully.
At its simplest you can create a table containing only a single field by specifying the name you want to give the table, the field name, and the type of data you want the field to contain.
CREATE TABLE Names
(FirstName VARCHAR (20), LastName VARCHAR (20));
The command(s) completed successfully.
This example shows how to include more than one field, and also limit the size of those fields by stating the size in parentheses after the data type declaration.
CREATE TABLE Names
(FirstName VARCHAR (20), LastName VARCHAR (20) NOT NULL);
The command(s) completed successfully.
By including the NOT NULL expression at the end of the declaration for a specific field, it can be required that this particular field always have valid data entered into it. However, if the data entered does not meet the requirements, a warning message will be displayed.
CREATE TABLE Names
(FirstName VARCHAR (20), LastName VARCHAR (20), DateOfBirth DATETIME,
CONSTRAINT MultiConstraint UNIQUE(FirstName, LastName, DateOfBirth));
The command(s) completed successfully.
Restrictions can also be placed on the data, or combinations of data, that are to be entered. This can be accomplished using the CONSTRAINT clause. This example expands on the previous ones by adding a Date of Birth field and requiring that the combination of data in all three fields be unique. The multifieldindex must be a unique name within the database.
Note:
Microsoft warns, "The Microsoft Jet database engine doesn't support the use of any DDL statements with databases produced by any other database engine. Use the DAO (Data Access Objects) Create methods instead."