<@U0A71G31CDV> ALTER TABLE mytable DROP COLUMN pai...
# questions-and-troubleshooting
l
@Rocky ALTER TABLE mytable DROP COLUMN paid_tern; how to undo drop colum?
r
In StarRocks, there is no direct "undo" command (like
RECOVER COLUMN
) to restore a column once the
DROP COLUMN
operation has finished. However, depending on whether the operation is still in progress, you may have options: 1. Check if the operation is still running
ALTER TABLE
operations in StarRocks are asynchronous. If the table is large, the drop might still be processing.
Copy code
sql
SHOW ALTER TABLE COLUMN;
Look for your table in the list. If the State is
PENDING
or
RUNNING
, you can cancel it. 2. Cancel the operation (if still running) If the job is not yet finished, run the following command immediately to stop the drop:
Copy code
sql
CANCEL ALTER TABLE COLUMN FROM mytable;
If this succeeds, the column will remain in the table. 3. If the operation has already finished If the state is
FINISHED
, the column metadata has been removed and the data is no longer accessible. Your recovery options are: * Restore from Backup: If you have performed a
BACKUP
to a repository (like S3 or HDFS) prior to the drop, you can use the
RESTORE
command to recover the table. * Re-add and Re-load: If you don't have a backup, you must manually add the column back and re-import the data for that column:
Copy code
sql
    ALTER TABLE mytable ADD COLUMN paid_tern <type>;
    -- Then re-run your ETL/Load process for this specific column.
* Iceberg/External Tables: If you are using an Iceberg catalog, you might be able to use the
rollback_to_snapshot
procedure, but this does not apply to native StarRocks (OLAP) tables. Note on the
RECOVER
command:
You may see documentation for the
RECOVER
statement (e.g.,
RECOVER TABLE mytable
), but please note this only works for entire tables, databases, or partitions that were deleted using
DROP TABLE
. It cannot be used to recover a single column dropped via
ALTER TABLE
. Referencesadministration/Data_recovery.mdbest_practices/query_tuning/schema_tuning.mdsql-reference/sql-statements/backup_restore/RECOVER.mdsql-reference/sql-statements/table_bucket_part_index/ALTER_TABLE.mdfaq/operation_maintenance_faq.mdsql-reference/sql-statements/table_bucket_part_index/CANCEL_ALTER_TABLE.mddata_source/catalog/iceberg/procedures.mdsql-reference/sql-statements/generated_columns.md