Creating Tables

CREATE TABLE Documents
(
    doc_id INTEGER NOT NULL PRIMARY KEY,
    doc_name VARCHAR(100NOT NULL,
    doc_cost DECIMAL(102)
); 

-- or

CREATE TABLE Documents
(
    doc_id INTEGER NOT NULL,
    doc_name VARCHAR(100NOT NULL,
    doc_cost DECIMAL(102),
    PRIMARY KEY (doc_id)
);

-- or

CREATE TABLE Documents
(
    doc_id INTEGER NOT NULL,
    doc_name VARCHAR(100NOT NULL,
    doc_cost DECIMAL(102),
    CONSTRAINT PK_Documents PRIMARY KEY (doc_id)
);


The first syntax is merely a shortcut allowing you to specify the column and add an index on it in a single clause. This works out fine in cases where you simply want to create a column and add an index on it.

You'll need to use the second syntax if you want to do something more complicated, such as adding an index based on multiple columns rather than a single column.

In the third syntax, you can specify the name of the primary key after the keyword CONSTRAINT.