The Darker Side of ALTER TABLE

If you frequently find yourself immersed into the MySQL world, there's probably no need to explain to you what SQL queries are and what they do. Chances are, you know them like your five fingers. SELECT queries allow us to read data, INSERT queries allow us to insert data into a given database, UPDATE queries allow us to update data for certain rows or for the entire table if we wish, DELETE queries let us delete records from a table, etc. If you've ever dug deeper into the world of MySQL though, you must know that there is one more query that is very important for both database administrators and developers — that query is ALTER TABLE.

What Is ALTER TABLE?

Simply put, ALTER TABLE is a query in MySQL that allows us to modify (or ALTER) the structure of a table. The things that ALTER TABLE can do are numerous — ALTER TABLE can be used to change names of tables or columns, or add or modify columns as well. On its end though, ALTER TABLE is mostly used when indexes are involved — when developers need to add indexes, they change the structure of their tables, and that's where ALTER TABLE comes into play once again.

CategoriesUncategorized