Help Center/ TaurusDB/ FAQs/ Database Usage/ How Do I Add Columns Using INSTANT?
Updated on 2024-09-05 GMT+08:00

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

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner of the page, choose Databases > GaussDB(for MySQL).
  4. 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.

  5. On the displayed login page, enter the correct username and password and click Log In.
  6. On the top menu bar, choose SQL Operations > SQL Query.
  7. 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