forked from docs/doc-exports
Reviewed-by: Kacur, Michal <michal.kacur@t-systems.com> Co-authored-by: Yang, Tong <yangtong2@huawei.com> Co-committed-by: Yang, Tong <yangtong2@huawei.com>
6.8 KiB
6.8 KiB
Adding a Column
Function
The ADD COLUMNS command is used to add a column to an existing table.
Syntax
ALTER TABLE Table name ADD COLUMNS(col_spec[, col_spec ...])
Parameter Description
Parameter |
Description |
---|---|
tableName |
Table name. |
col_spec |
Column specifications, consisting of five fields, col_name, col_type, nullable, comment, and col_position.
|
Example
alter table h0 add columns(ext0 string); alter table h0 add columns(new_col int not null comment 'add new column' after col1); alter table complex_table add columns(col_struct.col_name string comment 'add new column to a struct col' after col_from_col_struct);
Response
You can run the DESCRIBE command to view the new column.
Parent topic: SparkSQL Schema Evolution and Syntax Description