.alter-merge table.alter-merge table

.alter-merge table 命令:The .alter-merge table command:

  • 保护现有列中的数据Secures data in existing columns
  • 将新列、docstring 和文件夹添加到现有表中Adds new columns, docstring, and folder, to an existing table
  • 必须在指定表名范围的特定数据库的上下文中运行Must run in the context of a specific database that scopes the table name
  • 需要表管理员权限Requires Table Admin permission


.alter-merge 命令使用不当可能会导致数据丢失。Using the .alter-merge command incorrectly may lead to data loss.


.alter-merge 有一个对应的 .alter 表命令,它具有类似的功能。The .alter-merge has a counterpart, the .alter table command that has similar functionality. 有关详细信息,请参阅 .alter tableFor more information, see .alter table


.alter-merge table TableName (columnName:columnType, ...) [with ([docstring = Documentation] [, folder = FolderName] )] .alter-merge table TableName (columnName:columnType, ...) [with ([docstring = Documentation] [, folder = FolderName] )]

指定表列:Specify the table columns:

  • 你指定的但不存在的列会添加到现有架构的末尾。Columns that don't exist and which you specify, are added at the end of the existing schema.
  • 如果传递的架构不包含某些表列,这些列不会被删除。If the passed schema doesn't contain some table columns, the columns won't be deleted.
  • 如果使用其他类型指定现有列,该命令会失败。If you specify an existing column with a different type, the command will fail.


更改之前,请使用 .show table [TableName] cslschema 获取现有列架构。Use .show table [TableName] cslschema to get the existing column schema before you alter it.

此命令将如何影响数据?How will the command affect the data?

  • 该命令实际上不修改现有数据。Existing data isn't physically modified by the command. 已删除的列中的数据会被忽略。Data in removed columns is ignored. 新列中的数据被假定为 null。Data in new columns is assumed to be null.
  • 根据群集的配置方式,即使没有用户交互,数据引入也可能会修改表的列架构。Depending on how the cluster is configured, data ingestion might modify the table's column schema, even without user interaction. 更改表的列架构时,请确保引入操作不会添加命令随后要删除的必需列。When you make changes to a table's column schema, ensure that ingestion won't add needed columns that the command will then remove.


.alter-merge table MyTable (ColumnX:string, ColumnY:int) 
.alter-merge table MyTable (ColumnX:string, ColumnY:int) with (docstring = "Some documentation", folder = "Folder1")