How Do I Add Columns Using INSTANT?
GaussDB(for MySQL) is compatible with open-source MySQL 8.0.22, so you can use ALGORITHM=INSTANT to quickly add columns, preventing lock waiting from affecting services or SQL statement execution timeout.
Constraints
- Columns can be added only in one statement. If there are other non-INSTANT operations in the same statement, columns cannot be added immediately.
- Columns can be added only at the end of existing columns.
- COMPRESSED row format is not supported.
- Tables that already have full-text indexes are not supported.
If a table has a full-text index, you must run the OPTIMIZE TABLE statement on the table after deleting the full-text index.
- Temporary tables are not supported.
- A new field cannot have a default value.
Procedure
- Log in to the management console.
- Click in the upper left corner and select a region and project.
- Click in the upper left corner of the page, choose .
- On the Instances page, locate the instance and click Log In in the Operation column.
Alternatively, on the Instances page, click the instance name to go to the Basic Information page. Click Log In in the upper right corner of the page.
- On the displayed login page, enter the correct username and password and click Log In.
- On the top menu bar, choose SQL Operations > SQL Query.
- Run the following SQL statement to quickly add a column:
ALTER TABLE table_name ADD COLUMN column_name column_definition, ALGORITHM=INSTANT;
- table_name: table name
- column_name: column name
- column_definition: column remarks
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot