Alter Table Query
Alter Table query is used to modify data structure.
Add Columns
ALTER TABLE table_name
ADD column_name [DEFAULT value]
[FIRST|LAST|AFTER column|BEFORE column]
ALTER TABLE table_name
ADD (column_name [DEFAULT value] [, column_name [DEFAULT value] ...])
[FIRST|LAST|AFTER column|BEFORE column]
- table_name
- identifier or Table Object
- column_name
- identifier
- value
- value
If default value is not specified, new fields are set null.
- column
- field reference
LAST is the default position.
Drop Columns
ALTER TABLE table_name DROP column
ALTER TABLE table_name DROP (column [, column ...])
- table_name
- identifier or Table Object
- column
- field reference
Rename Column
ALTER TABLE table_name RENAME old_column_name TO new_column_name
- table_name
- identifier or Table Object
- old_column_name
- field reference
- new_column_name
- identifier
Set Attribute
Set file attributes. File attributes is used to create or update files by the results of queries.
Changes to the file attributes are retained until the end of the transaction.
ALTER TABLE table_name SET attribute TO value
- table_name
- identifier or Table Object
- attribute
- identifier
name type description FORMAT string Format DELIMITER string Field delimiter for CSV DELIMITER_POSITIONS string Delimiter positions for Fixed-Length Format JSON_ESCAPE string JSON escape type ENCODING string File Encoding LINE_BREAK string Line Break HEADER boolean Write header line in the file ENCLOSE_ALL boolean Enclose all string values in CSV PRETTY_PRINT boolean Make JSON output easier to read - value
- value or identifier