The Mysql5.5 table is InnoDB and the field is named "type". It is a common field and is not included in any index primary key. The type field already has two values & #039; a & #039;, & #039; B & #039;. I want to add a value for it now & #039; c & #039;, so the modification statement: {code ...} I want to know how to execute the preceding statement... the Mysql5.5 table is InnoDB and the field is named
type
Is a common field and is not contained in any index/primary key.
type
The field already has two values.'A','B'Now I want to add a value for it.'C'So there is a modification statement:
ALTER TABLE `table` MODIFY COLUMN `type` enum('a','b','c');
How long does it take for me to execute the preceding statement?
I mainly want to know that because this field does not involve indexes, does the modification time have to be related to the records of the table?
Let me estimate for you. I have a plan to prepare for the downtime. Thank you!
Reply content:
The Mysql5.5 table is InnoDB and the field is namedtype
Is a common field and is not contained in any index/primary key.
type
The field already has two values.'A','B'Now I want to add a value for it.'C'So there is a modification statement:
ALTER TABLE `table` MODIFY COLUMN `type` enum('a','b','c');
How long does it take for me to execute the preceding statement?
I mainly want to know that because this field does not involve indexes, does the modification time have to be related to the records of the table?
Let me estimate for you. I have a plan to prepare for the downtime. Thank you!
I recently talked about this in high-performance mysql (the third edition. Modify column will lead to table reconstruction (internal implementation is to create a table with the latest structure, then import data, then delete the old table, rename the new table to the old table name ), therefore, if alter table xxx alter column is used slowly, it is directly modified. frm file so it will soon. It has nothing to do with the amount of table data.
The other method works the same way. It is modified. frm file: 1. create a new table for the new organization 2. flush tables with read lock. disable tables in use and disable any tables from being opened. 3. Switch the. frm file 4. unlock tables to release the lock in step 2.
I haven't tried it in the last few nights. I should test it too.
Static long getAlterTable () {if (Database not backed up) {do backup getAlterTable ();} else {return test alter table time }};
You can see that percona modifies the table structure online. Online modification is supported.