Jonathan Wills
03/20/2026, 8:26 PMRocky
03/20/2026, 8:26 PMAFTER keyword to specify the location of new columns, you cannot use the parenthetical syntax (e.g., ADD COLUMN (col1, col2)) to apply a single AFTER to both.
Instead, you should specify each column with its own ADD COLUMN clause within a single ALTER TABLE statement. This allows you to place each one exactly where you want it.
Recommended Syntax
To add multiple columns to specific locations in one command, follow this pattern:
sql
ALTER TABLE <table_name>
ADD COLUMN col1 INT AFTER existing_col,
ADD COLUMN col2 INT AFTER col1;
Key Points:
* Parentheses Syntax: Using ADD COLUMN (col1 type, col2 type) is for adding multiple columns at once, but it does not support the AFTER or FIRST keywords. Columns added this way are typically appended to the end.
* Individual Clauses: By repeating the ADD COLUMN keyword (separated by commas), you can specify a unique position for every new column.
* Single Transaction: Even though you are repeating ADD COLUMN, this is still a single ALTER TABLE operation, which is more efficient than running multiple separate ALTER TABLE statements.
You can find more details and examples in the StarRocks ALTER TABLE documentation.
References
• sql-reference/sql-statements/table_bucket_part_index/ALTER_TABLE.md