ALTER TABLE statement modifies the table accordingly
CREATE TABLE Books
(
BookID SMALLINT NOT NULL,
BookName VARCHAR(40) NOT NULL,
PubID SMALLINT NOT NULL DEFAULT 'Unknown'
)
ENGINE=INNODB;
ALTER TABLE Books
ADD PRIMARY KEY (BookID),
ADD CONSTRAINT fk_1 FOREIGN KEY (PubID) REFERENCES Publishers (PubID),
ADD COLUMN Format ENUM('paperback', 'hardcover') NOT NULL AFTER BookName;
Related examples in the same category