日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

hive mysql命令,Hive数据库常用命令

發(fā)布時間:2025/3/12 数据库 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hive mysql命令,Hive数据库常用命令 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

收藏一些Hive數(shù)據(jù)庫常用命令,方便平時準(zhǔn)備測試數(shù)據(jù)集。

查看庫、創(chuàng)建普通Hive表:

show databases;

user lch_databases;

show tables;

create table lch_user_table(

int id,

name varchar(8),

birthday date,

salary double(24.7),

dd1 decimal(18,4)

);

alert table lch_user_table add columns(性別 string comment '男女');

修改Hive表

alert table lch_user_table RENAME TO new_name;

alert table lch_user_table ADD COLUMNS (col_spec[, col_spec ...]);

alert table lch_user_table ADD COLUMNS(性別 string comment 男女');

alert table lch_user_table DROP [COLUMN] column_name;

alert table lch_user_table CHANGE column_name new_name new_type;

創(chuàng)建分區(qū)Hive表:

create table lch_test_table(

order_number string,

event_time string )

PARTITIONED BY(event_month string)

ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';

(1) 單分區(qū)建表

單分區(qū)表,按天分區(qū),在表結(jié)構(gòu)中存在id,content,dt三列。以dt為文件夾區(qū)分

create table day_table (id int, content string) partitioned by (dt string);

(2) 雙分區(qū)建表

雙分區(qū)表,按天和小時分區(qū),在表結(jié)構(gòu)中新增加了dt和hour兩列。先以dt為文件夾,再以hour子文件夾區(qū)分

create table day_hour_table (id int, content string) partitioned by (dt string, hour string);

向有分區(qū)的表插入數(shù)據(jù)

(1) 覆蓋現(xiàn)有分區(qū)數(shù)據(jù),如果沒有該指定分區(qū),新建該分區(qū),并且插入數(shù)據(jù)

INSERT OVERWRITE TABLE 庫名.表名 PARTITION(dt='2018-09-12',name='Tom', ...)

SELECT ... FROM 庫名.表名 where...

(2) 向現(xiàn)有的分區(qū)插入數(shù)據(jù) (之前的數(shù)據(jù)不會被覆蓋)

INSERT INTO TABLE 庫名.表名 PARTITION(dt='2018-09-12',name='Tom',...)

SELECT ... FROM 庫名.表名 WHERE ...

向無分區(qū)的表插入數(shù)據(jù)

(1) 覆蓋原有表里的數(shù)據(jù),命令和有分區(qū)的表類似,只是去掉后面的

PARTITION(dt=' ',name=' ')

insert overwrite table 庫名.表名

select ... frome 庫名.表名 where...

(2) 向現(xiàn)有的表插入數(shù)據(jù) (之前的數(shù)據(jù)不會被覆蓋)

insert into talbe 庫名.表名

select ... from 庫名.表名 where ...

insert into table lch_user_table values

('Lucy','2019-9-18',13493.13,0.12,'女');

跨庫復(fù)制表

CREATE TABLE NEWDB.NEW_TABLE2 AS select * from OLDDB.OLD_TABLE2;

批量執(zhí)行命令行

beeline -e "select count() from user;" >>output.txt

beeline -e "select count() from info;" >>output.txt

beeline -e "use bicoredata;" "show tables;" >>output.txt

總結(jié)

以上是生活随笔為你收集整理的hive mysql命令,Hive数据库常用命令的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。