Source Code
CREATE TABLE vehicles ( vehicleId INT, year INT NOT NULL, make VARCHAR(100) NOT NULL, PRIMARY KEY(vehicleId) );
MySQL ALTER TABLE
– Add columns to a table:
1) Add a column to a table:
ALTER TABLE vehicles ADD model VARCHAR(100) NOT NULL;
2) Add multiple columns to a table:
MySQL ALTER TABLE
– Modify columns:
1) Modify a column:
ALTER TABLE vehicles MODIFY note VARCHAR(100) NOT NULL;
2) Modify multiple columns:
ALTER TABLE vehicles MODIFY year SMALLINT NOT NULL, MODIFY color VARCHAR(20) NULL AFTER make;
MySQL ALTER TABLE
– Rename a column in a table
ALTER TABLE vehicles CHANGE COLUMN note vehicleCondition VARCHAR(100) NOT NULL;
No comments:
Post a Comment