show databases;OKdatabase_namecompanydefaultstaffTime taken: 0 424 seconds, Fetched: 3 row(s)2、 打開某個數(shù)據(jù)庫hive (staff)> use company;O ">
7、 創(chuàng)建一個新表,結(jié)構(gòu)與原先某個表相同
hive (company)> create table dept like department;
OK
Time taken: 0.086 seconds
創(chuàng)建后,顯示表結(jié)構(gòu):
hive (company)> desc dept;
OK
col_name data_type comment
id string
dname string
count int
Time taken: 0.052 seconds, Fetched: 3 row(s)
8、 重命名表
hive (company)> alter table dept rename to dept1;
OK
Time taken: 0.09 seconds
9、 給表增加字段
hive (company)> alter table staff add columns(aa int);
OK
Time taken: 0.099 seconds
查看結(jié)果驗證:
10、 刪除表數(shù)據(jù)(內(nèi)表)
刪除前,首先查看表數(shù)據(jù):
hive (company)> select * from staff;
OK
staff.id staff.name staff.sex
1 tom male
2 mary female
3 jack male
刪除表數(shù)據(jù):
hive (company)> truncate table staff;
OK
Time taken: 0.059 seconds
再次查詢表數(shù)據(jù):
hive (company)> select * from staff;
OK
staff.id staff.name staff.sex
Time taken: 0.041 seconds
11、 刪除表
hive (company)> drop table department;
OK
Time taken: 0.372 seconds
>>本文地址:http://uj2y2uok.com/zhuanye/2021/68694.html
聲明:本站稿件版權(quán)均屬中公教育優(yōu)就業(yè)所有,未經(jīng)許可不得擅自轉(zhuǎn)載。
1 您的年齡
2 您的學歷
3 您更想做哪個方向的工作?