You are on page 1of 3

tables

hive managed
create table t1 (id int);
show tables;
describe t1;
show create table t1;
describe extended t1;
describe formated t1;
quit;
create table t2 (id int)
LOCATION '/user/home/t1';
external table
create external table t3 (id int)
location '/user/home/exter';
drop table t1;
mysql -u root
show databases;
use hive;
show tables;
LOAD DATA LOCAL INPATH 'sourcedata.txt' into table sourcetable;
create table t2 like t1;
LOAD DATA INPATH '/user/hive/warehouse/t1' into table t2; (move)
create table t2_seq (id int , name string)
STORED AS SequenceFile;
insert into table t2_seq
select * from t2;
create table t2_avro (id int , name string)
STORED AS AVRO;
create table t2_orc (id int , name string)
STORED AS ORC;
create table t2_parq (id int , name string)
STORED AS PARQUET;
show tables;
insert overwrite directory 'user/sample/hive_out'
select * from t1;
CREATE TABLE students (name VARCHAR(64), age INT, gpa DECIMAL(3, 2))
CLUSTERED BY (age) INTO 2 BUCKETS STORED AS ORC;

INSERT INTO TABLE students


VALUES ('fred flintstone', 35, 1.28), ('barney rubble', 32, 2.32);
set -v;
set mapreduce.job.reduces=2;
insert overwrite directory '/user/hive/h1'
select year, name from eu distribute by year sort by year,name;
LOAD DATA INPATH 'hdfs_file_or_directory_path' [OVERWRITE] INTO TABLE tablenam
e
[PARTITION (partcol1=val1, partcol2=val2 ...)]
LOAD DATA LOCAL INPATH 'sourcedata.txt' into table sourcetable;

create table tabname like taboldname


create table tabname as
select * from oldtab limit 5;

sed -i 's/"//g' your_file_name


create view medium_country as
select * from world where name = "so and so"
create table cities_part (name string, population:int)
partitioned by (state string)
insert into table cities_part
PARTITIONED (state)
select name, population, state from cities;
CREATE TABLE order (
username
STRING,
orderdate
STRING,
amount
DOUBLE,
tax
DOUBLE,
) PARTITIONED BY (company STRING)
CLUSTERED BY (username) INTO 25 BUCKETS;
create external table s1 (id int ,score int)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LOCATION '/test/s1';
create external table s1 (id int ,score int)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'

LOCATION '/test/s1';

You might also like