SQL is the most wanted skill in Data Science!! π±
A Beginner's Guide to MySQL basic queries - Part 3!! π
Making mistakes while creating tables is common. Let's learn how to update and fix them! π¬
Thread π§΅
β
UPDATE THE TABLE
1. Add a column to the existing table:-
ALTER table table_name ADD (column_name datatype);
(Note: Adding a constraint to a column is optional)
π E.g., Adding the ADDRESS column to the classroom1 table.
2. Add MULTIPLE columns at once:-
ALTER table table_name ADD (colname1 datatype1, colname2 datatype2);
π E.g., Adding Email_id and ContactNo columns to the classroom1 table
3. Changing the name of a column:-
ALTER table table_name CHANGE old_column_name new_column_name datatype;
π E.g., Changing the column name rollno to ID
4. Modifying (Changing) the datatype of the existing column:-
ALTER table table_name MODIFY column_name datatype;
π E.g., Changing the datatype of the Address column to datatype CHAR.
5. Delete a column:-
ALTER table table_name DROP column column_name;
π E.g., Dropping the column EmailID from the classroom1 table.
6. Delete multiple columns at once:-
ALTER table table_name DROP column colname1, DROP column colname2;
π E.g., Dropping the columns ContactNo & Address from the classroom1 table.
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.