Download Informix Guide to SQL: Tutorial, Version 6.0

Transcript
Creating the Database
•
ANSI-compliant logging. This is the same as regular logging, but the ANSI
rules for transaction processing are also enabled. (See the discussion of
ANSI-compliant databases in Chapter 1 of the Informix Guide to SQL: Reference.)
CREATE DATABASE std_rules_db WITH LOG IN 'a-log-file' MODE
ANSI
You can add a transaction log to a nonlogged database later using the START
DATABASE statement.
Using CREATE TABLE
Use the CREATE TABLE statement to create each table you designed in the
data model. This statement has a complicated form, but it is basically a list of
the columns of the table. For each column, you supply the following
information:
•
•
•
•
•
The name of the column
The data type (from the domain list you made)
If the column (or columns) is a primary key, the constraint PRIMARY KEY
If the column (or columns) is a foreign key, the constraint FOREIGN KEY
If the column is not a primary key and should not allow nulls, the
constraint NOT NULL
• If the column is not a primary key and should not allow duplicates, the
constraint UNIQUE
• If the column has a default value, the constraint DEFAULT
• If the column has a check constraint, the constraint CHECK
In short, the CREATE TABLE statement is an image in words of the table as
you drew it in the data model diagram. Figure 9-5 shows the statements for
the telephone-directory model whose diagram is shown in Figure 8-16 on
page 8-31.
9-24 Implementing Your Data Model