Sukriti Macker Profile picture
Grad Student at NYU πŸ‡ΊπŸ‡ΈπŸ’œ | Let's talk about SQL, Python, Statistics, Machine Learning and Data Science

Jun 6, 2021, 7 tweets

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.

Keep scrolling