Crear tabla de colmena usando "como seleccionar" o "me gusta" y también especificar delimitador
Es posible hacer un
create table <mytable> as select <query statement>
Usando
row format delimited fields terminated by '|';
O hacer un
create table <mytable> like <other_table> row format delimited fields terminated by '|';
El Manual de Idiomas parece indicar que no.. pero algo me hace cosquillas que había logrado esto en el pasado.
3 answers
Crear tabla como seleccionar (CTA) es posible en el subárbol.
Puedes probar el siguiente comando:
CREATE TABLE new_test
row format delimited
fields terminated by '|'
STORED AS RCFile
AS select * from source where col=1
- El destino no puede ser particionado tabla.
- El objetivo no puede ser una tabla externa.
- Copia la estructura así como los datos
Crear un tipo de tabla también es posible en Hive.
- Simplemente copia la definición de la tabla de origen.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-11 20:40:33
Digamos que tenemos una tabla externa llamada 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')
-
Para crear una tabla
person
comoemployee
CREATE TABLE person LIKE employee;
-
Para crear una tabla externa
person
comoemployee
CREATE TABLE person LIKE employee LOCATION 'maprfs:/user/hadoop/data/person';
A continuación, utilizar
DESC person;
para ver el esquema de tabla recién creado.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-07 23:10:34
create table newtable as select column1, column2, column3 from oldtable
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-11-24 13:49:54