In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "what are the basic operations of Hive database warehouse", the content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn this article "what are the basic operations of Hive database warehouse".
Hive Database Repository basics View databases in hive
Show databases;
View tables in hive
Show tables;
View table structure information
DESCRIBE table_name;
Create table:
CREATE TABLE daxiong (id INT, name STRING);
Create a new table daxiong1 with the same structure as daxiong
Create table daxiong1 like daxiong;
Create partition table
create table logs(ts bigint,line string) partitioned by (dt String,country String);
load table data
(from linux (ext3/ext4 file system to hive))
A files are spaces, b files are tabs; see the results later.
hive> create table ha(id int,name string)
> row format delimited
> fields terminated by '\\t'
> stored as textfile;
OK
Time taken: 0.28 seconds
Note: The [ROW FORMAT DELIMITED] keyword is used to set the column separators supported by the created table when loading data.
[STORED AS file_format] keyword is used to set the data type of the loaded data. The default is TEXTFILE. If the file data is plain text, use [STORED AS TEXTFILE], and then copy it directly from the local to HDFS. Hive can directly identify the data.
Import data from HDFS to Hive tables
Uploading from linux to hdfs:
load data inpath '/user/c' into table ha;
Export to local file system
insert overwrite local directory '/home/hdfs/d' select * from ha;
Export to HDFS
insert overwrite directory '/user/d select * from ha;
View:
Hive Connect hbase (data transfer)
Create a table classes with 1 column family user
create 'classes','user'
View table structure
describe 'classes'
join the data
put 'classes','001','user:name','jack'put 'classes','001','user:age','20' put 'classes','002','user:name','liza' put 'classes','002','user:age','18'
View data in classes
scan 'classes'
Create an external hive table, query validation:
create external table classes(id int, name string, age int) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,user:name,user:age") TBLPROPERTIES("hbase.table.name" = "classes");
select * from classes;
Add data to Hbase
put 'classes','003','user:age','1820183291839132'
scan 'classes'
Hive query, see new data
select * from classes;
null, because 3 has no name, so fill Null, and age is Null because it exceeds the maximum value, there is validation in the screenshot
The above is "Hive database warehouse basic operation what" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.