show databases;OKdatabase_namecompanydefaultstaffTime taken: 0 424 seconds, Fetched: 3 row(s)2、 打開某個數(shù)據(jù)庫hive (staff)> use company;O ">
基礎命令
1、 查看所有的數(shù)據(jù)庫
hive (default)> show databases;
OK
database_name
company
default
staff
Time taken: 0.424 seconds, Fetched: 3 row(s)
2、 打開某個數(shù)據(jù)庫
hive (staff)> use company;
OK
Time taken: 0.015 seconds
3、 顯示當前數(shù)據(jù)庫下所有的表
hive (company)> show tables;
OK
tab_name
staff
Time taken: 0.028 seconds, Fetched: 1 row(s)
4、 顯示表結構
hive (company)> desc staff;
OK
col_name data_type comment
id int
name string
sex string
Time taken: 0.194 seconds, Fetched: 3 row(s)
5、 創(chuàng)建表
hive (company)> create table department(
> id string,
> dname string,
> count int)
> row format delimited fields terminated by '\t';
OK
Time taken: 0.055 seconds
6、 往表中加載數(shù)據(jù)
準備數(shù)據(jù)文件:
[root@node1 test]# cat department.txt
001 d1 10
002 d2 8
003 d3 12
往表中加載數(shù)據(jù):
hive (company)> load data local inpath '/opt/test/department.txt' overwrite table department;
Loading data to table company.department
Table company.department stats: [numFiles=1, numRows=0, totalSize=29, rawDataSize=0]
OK
Time taken: 0.203 seconds
>>本文地址:http://nfbqydst.cn/zhuanye/2021/68694.html
聲明:本站稿件版權均屬中公教育優(yōu)就業(yè)所有,未經(jīng)許可不得擅自轉載。
1 您的年齡
2 您的學歷
3 您更想做哪個方向的工作?