MapReduce服务 MRS-ALTER TABLE修改表结构:使用示例
时间:2025-02-12 14:58:21
使用示例
--给表t1增加列test01 ALTER TABLE t1 ADD COLUMN test01 String DEFAULT 'defaultvalue';--查询修改后的表t1desc t1┌─name────┬─type─┬─default_type─┬─default_expression ┬─comment─┬─codec_expression─┬─ttl_expression─┐│ id │ UInt8 │ │ │ │ │ │ │ name │ String │ │ │ │ │ │ │ address │ String │ │ │ │ │ ││ test01 │ String │ DEFAULT │ 'defaultvalue' │ │ │ │└───────┴────┴────────┴────────── ┴───── ┴──────────┴─────────┘--修改表t1列name类型为UInt8ALTER TABLE t1 MODIFY COLUMN name UInt8;--查询修改后的表t1desc t1┌─name────┬─type─┬─default_type─┬─default_expression ┬─comment─┬─codec_expression─┬─ttl_expression─┐│ id │ UInt8 │ │ │ │ │ │ │ name │ UInt8 │ │ │ │ │ │ │ address │ String │ │ │ │ │ ││ test01 │ String │ DEFAULT │ 'defaultvalue' │ │ │ │└───────┴────┴────────┴────────── ┴───── ┴──────────┴─────────┘--删除表t1的列test01ALTER TABLE t1 DROP COLUMN test01;--查询修改后的表t1desc t1┌─name────┬─type─┬─default_type─┬─default_expression ┬─comment─┬─codec_expression─┬─ttl_expression─┐│ id │ UInt8 │ │ │ │ │ │ │ name │ UInt8 │ │ │ │ │ │ │ address │ String │ │ │ │ │ │└───────┴────┴────────┴────────── ┴───── ┴──────────┴─────────┘
support.huaweicloud.com/cmpntguide-mrs/mrs_01_24204.html