hive表操作
阿新 • • 發佈:2018-12-22
Use dbname; //庫名
Show tables; //檢視所有的表
Show partitions 表名; //檢視分割槽 dt
select * from dbName.tableName where id=6784500 and dt='2018-07-24';
quit; //退出
用"use 庫名; show create table 表名;" 來檢視一個已經存在的表,檢視location路徑
hadoop fs -ls location路徑
dl_diff_sku_latest=`hadoop fs -ls /dl_diff_sku/*.latest| tail -n 1 | awk -F'/' '{print $NF}' | awk -F'.' '{print $1}'`
hadoop fs -get /dl_diff_sku/$dl_diff_sku_latest
CREATE TABLE `recommend_promotion_address`(
`id` bigint,
`x` string,
`y` string)
PARTITIONED BY (
`dt` string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'hdfs://ns1013
TBLPROPERTIES (
'transient_lastDdlTime'='1539090248')