Handy MySQL Commands-II

Ankit Kumar Rajpoot
2 min readJun 22, 2022

--

  1. To update info already in a table.
mysql> UPDATE Persons SET PersonId = 2 where FirstName = 'Ankur';

2. Delete a row(s) from a table.

mysql> DELETE from Persons where PersonId = 2;

3. Add a new column to db.

mysql> alter table Persons add column newClm varchar(20);

4. Delete a column.

mysql> alter table Persons drop column newClm;

5. Change column name.

mysql> alter table Persons change column FirstName First varchar(20);

6. Make a unique column so you get no dupes.

mysql> alter table Persons add unique (PersonId);

7. Make a column bigger.

mysql> alter table Persons modify First varchar(255);

8. Delete unique from table.

mysql> alter table Persons drop index PersonId;

That’s it for this time! I hope you enjoyed this post. As always, I welcome questions, notes, comments and requests for posts on topics you’d like to read. See you next time! Happy Coding !!!!!

--

--

Ankit Kumar Rajpoot
Ankit Kumar Rajpoot

Written by Ankit Kumar Rajpoot

I’m a MERN Developer. ( Redux | AWS | Python ) I enjoy taking on new things, building skills, and sharing what I’ve learned.

No responses yet