Examples of data-definition queries

Examples of data-definition queries

Creating a table

This data-definition query uses the CREATE TABLE statement to create a table named Friends. The statement includes the name and data type for each field in the table and assigns the FriendID field an index that marks it as the primary key.

CREATE TABLE Friends
([FriendID] integer,
[LastName] text,
[FirstName] text,
[Birthdate] date,
[Phone] text,
[Notes] memo,
CONSTRAINT [Index1] PRIMARY KEY ([FriendID]));

Creating an index

This data-definition query uses the CREATE INDEX statement to create a multiple-field index on the LastName and FirstName fields.

CREATE INDEX NewIndex 
ON Friends ([LastName], [FirstName]);