MAPREDUCE服务 MRS-CREATE TABLE LIKE:示例

时间:2024-07-02 16:39:32

示例

  • 创建基础表order01和order02
    CREATE TABLE order01(id int,name string,tel string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'STORED AS TEXTFILE;
    CREATE TABLE order02(sku int, sku_name string, sku_describe string);
  • 创建表orders_like01,它将包含表order01定义的列及表属性
    CREATE TABLE orders_like01 like order01 INCLUDING PROPERTIES;
  • 创建表orders_like02,它将包含表order02定义的列,并将表的存储格式设置为‘TEXTFILE’
    CREATE TABLE orders_like02 like order02 STORED AS TEXTFILE;
  • 创建表orders_like03,它将包含表order01定义的列及表属性,order02定义的列,以及额外的列c1和c2
    CREATE TABLE orders_like03 (c1 int,c2 float,LIKE order01 INCLUDING PROPERTIES,LIKE order02);
  • 创建表orders_like04和orders_like05,它们都会包含同一个表order_partition的定义,但orders_like04不会包含分区键信息,而orders_like05会包含分区键的信息
    CREATE TABLE order_partition(id int,name string,tel string) PARTITIONED BY (sku int);
    CREATE TABLE orders_like04 (like order_partition);
    CREATE TABLE orders_like05 like order_partition;
    DESC orders_like04;
     Column |  Type   | Extra | Comment 
    --------|---------|-------|---------
     id     | integer |       |         
     name   | varchar |       |         
     tel    | varchar |       |         
     sku    | integer |       |         
    (4 rows)
    
    DESC orders_like05;
    
     Column |  Type   |     Extra     | Comment 
    --------|---------|---------------|---------
     id     | integer |               |         
     name   | varchar |               |         
     tel    | varchar |               |         
     sku    | integer | partition key |         
    (4 rows)
support.huaweicloud.com/cmpntguide-lts-mrs/mrs_01_300132.html