I am working with Postgres DB for the first time and when I try to create my third and last table with foreign keys, I get an error which I don't know how to fix it.
Can anyone help?
CREATE TABLE Customer(
CUSTID SERIAL PRIMARY KEY,
Fname CHAR(20),
Lname CHAR(20),
StAdsress CHAR(30),
City CHAR(20),
ProvSt CHAR(2),
HPhone CHAR(12),
WPhone CHAR(12),
Pemail CHAR(30),
Wemail CHAR(30),
CDate TIMESTAMP NOT NULL
);
CREATE TABLE Catalog (
CATID SERIAL PRIMARY KEY,
ItemName CHAR(30),
ItemDesc CHAR(30),
ItemType CHAR(15),
ItemWeight numeric(4,2),
ItemSize CHAR(10),
QuantityOnHand INTEGER,
PRICE numeric(4,2),
CreateDate TIMESTAMP NOT NULL
);
CREATE TABLE Order (
ORDID SERIAL NOT NULL,
CUSTID INT,
CATID INT,
Qty INTEGER,
OrderDate TIMESTAMP,
SubTotal NUMERIC(4,2),
PRIMARY KEY (ORDID, CUSTID, CATID),
FOREIGN KEY (CUSTID)
REFERENCES Customer (CUSTID),
FOREIGN KEY (CATID)
REFERENCES Catalog (CATID)
);
ERROR: syntax error at or near "Order" LINE 1: CREATE TABLE Order ( ^ SQL state: 42601