Updated on 2025-04-21 GMT+08:00

ADD COLUMNS

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

Table 1 ADD COLUMNS parameters

Parameter

Description

tableName

Table name.

col_spec

Column specifications, consisting of four fields, col_name, col_type, nullable, and comment.

  • col_name: name of the new column. It is mandatory.

    Adding new subcolumns to nested columns is currently not supported.

  • col_type: type of the new column. It is mandatory.
  • nullable: whether the new column can be null. The value can be left empty.
  • comment: comment of the new column. The value can be left empty.

Required Permissions

  • SQL permissions
Table 2 Permissions required for executing ALTER TABLE

Permission Description

ALTER permission on a table

  • Fine-grained permission: dli:table:alter
  • Metadata services provided by LakeFormation. Refer to the LakeFormation documentation for details on permission configuration.

Example

alter table h0 add columns(ext0 string);

alter table h0 add columns(new_col int comment 'add new column');

alter table delta.`obs://bucket_name0/db0/delta_table0` add columns(new_col string);

Response

You can run the DESCRIBE command to view the new column.