Create hive table using “as select” or “like” and also specify delimiter

后端 未结 3 1173
粉色の甜心
粉色の甜心 2020-12-14 00:21

Is it possible to do a

create table as select

using

row format delimited fields termi         


        
3条回答
  •  醉梦人生
    2020-12-14 00:55

    Let's say we have an external table called employee

    hive> SHOW CREATE TABLE employee;
    OK
    CREATE EXTERNAL TABLE employee(
      id string,
      fname string,
      lname string, 
      salary double)
    ROW FORMAT SERDE
      'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
    WITH SERDEPROPERTIES (
      'colelction.delim'=':',
      'field.delim'=',',
      'line.delim'='\n',
      'serialization.format'=',')
    STORED AS INPUTFORMAT
      'org.apache.hadoop.mapred.TextInputFormat'
    OUTPUTFORMAT
      'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
    LOCATION
      'maprfs:/user/hadoop/data/employee'
    TBLPROPERTIES (
      'COLUMN_STATS_ACCURATE'='false',
      'numFiles'='0',
      'numRows'='-1',
      'rawDataSize'='-1',
      'totalSize'='0',
      'transient_lastDdlTime'='1487884795')
    
    1. To create a person table like employee

      CREATE TABLE person LIKE employee;

    2. To create a person external table like employee

      CREATE TABLE person LIKE employee LOCATION 'maprfs:/user/hadoop/data/person';

    3. then use DESC person; to see the newly created table schema.

提交回复
热议问题