Ist es möglich, a
create table <mytable> as select <query statement>
mit
row format delimited fields terminated by '|';
oder um a
create table <mytable> like <other_table> row format delimited fields terminated by '|';
Das Sprachhandbuch scheint das nicht anzuzeigen .. aber etwas kitzelt mich das ich das in der Vergangenheit erreicht hatte.
Tabelle als Auswahl erstellen (CTAS) ist in Hive möglich.
Sie können den folgenden Befehl ausprobieren:
CREATE TABLE new_test
row format delimited
fields terminated by '|'
STORED AS RCFile
AS select * from source where col=1
Erstellen von Tabellen wie ist auch in Hive möglich.
Nehmen wir an, wir haben eine externe Tabelle namens 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')
So erstellen Sie eine person
-Tabelle wie employee
CREATE TABLE person LIKE employee;
So erstellen Sie eine person
externe Tabelle wie employee
CREATE TABLE person LIKE employee LOCATION 'maprfs:/user/hadoop/data/person';
dann benutze DESC person;
, um das neu erstellte Tabellenschema anzuzeigen.