4 ms·
This isn't a MySql problem; it's simply how databases work. When you change a table's structure by adding/removing/changing a column, any database (MySql, Oracl
by ScottWhigham 17y ago
This isn't a MySql problem; it's simply how databases work. When you change a table's structure by adding/removing/changing a column, any database (MySql, Oracle, DB2, etc) has to change every single row. To change all rows, that requires an "exclusive lock" on the table.
An ALTER TABLE statement that adds/removes/changes-data-types of a column requires what is called a "schema lock" - meaning that you must acquire exclusive access to the entire table so that you can fundamentally change each and every row. You can't add a new column to only "some" of the rows, right? You have to modify the entire table. In order to adhere to relational database standards, this must be an "atomic" operation: all or nothing. To do so, MySql locks the entire table.
There are no shortcuts that I know of. Sorry!