Programming Pandit

c/c++/c#/Javav/Python


Latest Update

Wednesday, December 2, 2020

SQL Queries for Ulter Update and Delete by G Krishna Chauhan

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:


ALTER TABLE vehicles ADD color VARCHAR(50), ADD note VARCHAR(255);




 


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