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.

Author: javadba, 2014-03-07

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
  1. El destino no puede ser particionado tabla.
  2. El objetivo no puede ser una tabla externa.
  3. Copia la estructura así como los datos

Crear un tipo de tabla también es posible en Hive.

  1. Simplemente copia la definición de la tabla de origen.
 61
Author: Venkatesh,
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')
  1. Para crear una tabla person como employee

    CREATE TABLE person LIKE employee;

  2. Para crear una tabla externa person como employee

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

  3. A continuación, utilizar DESC person; para ver el esquema de tabla recién creado.

 0
Author: Sakthivel,
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
 -2
Author: Avi Swarnkar,
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