Alter table: add primary key, foreign key and add column
Drop table Books;
CREATE TABLE Books
(
ID SMALLINT NOT NULL,
Name VARCHAR(40) NOT NULL,
PubID SMALLINT NOT NULL DEFAULT 'Unknown'
)
ENGINE=INNODB;
Describe Books;
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 Name;
Describe Books;
Related examples in the same category