Alter Table
The Airport extension supports table schema modifications through the standard SQL ALTER TABLE statement. The Arrow Flight server determines whether to permit and apply the requested alteration.
Example
For a DuckDB session to alter a table, a standard SQL ALTER TABLE statement is executed in a schema that is managed by the Airport extension.
-- Attach an Airport database
ATTACH 'example' (TYPE AIRPORT, location 'grpc://localhost:50312/');
-- Assume that there is a `main` schema
-- already in the `example` database
CREATE TABLE example.main.employees (
name varchar,
id integer
);
ALTER TABLE example.main.employees DROP COLUMN id;Arrow Flight Server Implementation Notes
The Airport extension invokes a DoAction Arrow Flight RPC with an action name corresponding to the specific alteration type.
Supported Alteration Operations
| Action Name | Description |
|---|---|
add_column |
Add a column to a table. |
add_constraint |
Add a constraint to a field. |
add_field |
Add a field to a structure. |
change_column_type |
Change the type of a column. |
drop_not_null |
Drop NOT NULL constraint from a field. |
remove_column |
Remove a column from a table. |
remove_field |
Remove a field from a structure. |
rename_column |
Rename a column. |
rename_field |
Rename a field in a structure. |
rename_table |
Rename a table. |
set_default |
Set a default value for a field. |
set_not_null |
Set a field to NOT NULL. |
Each alteration type accepts a specific parameter structure as defined in its respective documentation page.
Return Value: Most alteration actions return an updated FlightInfo structure reflecting the modified table schema. Actions like set_default and set_not_null do not return values but must raise an Arrow Flight exception on error.