hive 建庫建表插入資料
先上傳檔案
sftp> put /users/chenxin/downloads/hql50/hql50/score.txt /root/data/hql50
sftp> put /users/chenxin/downloads/hql50/hql50/teacher.txt /root/data/hql50
sftp> put /users/chenxin/downloads/hql50/hql50/course.txt /root/data/hql50
sftp> put /users/chenxin/downloads/hql50/hql50/student.txt /root/data/hql50
在hdfs 建資料夾 將傳上去的檔案存到hdfs中
hdfs dfs -mkdir /homework
hdfs dfs -put course.txt /homework
hdfs dfs -put score.txt /homework
hdfs dfs -put student.txt /homework
hdfs dfs -put teacher.txt /homework
去50070埠檢視是否傳上去了
hive 建庫用庫
create database homework;
use homewrok;
建表
create table if not exists course(
course_id int,course_name string,teacher_id int
) comment 'course table'
row format delimited
fields terminated by '\t'
lines terminated by '\n'
stored as textfile;
create table if not exists score(
student_id int,course_id int,score int
) comment 'score table'
row format delimited
fields terminated by '\t'
lines terminated by '\n'
stored as textfile;
create table if not exists student(
student_id int,student_name string,
student_birth string,student_*** string
) comment 'student table'
row format delimited
fields terminated by '\t'
lines terminated by '\n'
stored as textfile;
create table if not exists teacher(
teacher_id int,
display all 478 possibilities? (y or n)
ame string
) comment 'teacher table'
row format delimited
fields terminated by '\t'
lines terminated by '\n'
stored as textfile;
檢視表是否建完成
show tables;
將hdfs檔案中資料插入表中
load data inpath'/homework/course.txt' into table course;
load data inpath'/homework/score.txt' into table score;
load data inpath'/homework/student.txt' into table student;
load data inpath'/homework/teacher.txt' into table teacher;
檢視表中是否有資料
select * from teacher;
Mysql 建庫 建表 插入資料
檢視所有資料庫 show databases 新建test資料庫,建議不要用中文或者關鍵字,如果一定要用的化可以加反引號 引起來 charset 分為utf8 gbk create database test charset utf8 開啟test資料庫 use沒有退出資料庫的命令,但是可以檢視資料...
Hive 建表 插入資料 插入復合型別
新建hive表 create table test a timestamp b struct 下面可選 row format delimited fields terminated by t stored as parquet 檢視建好的表的結構 hive show create table tes...
hive建庫建表與資料匯入匯出
hive建表 hive分內部表與外部表,建立內部表時,會將資料移動到資料倉儲指向的路徑 若建立外部表,僅記錄資料所在的路徑,不對資料的位置做任何改變。在刪除表的時候,內部表的元資料和資料會被一起刪除,而外部表只刪除元資料,不刪除資料。這樣外部表相對來說更加安全些,資料組織也更加靈活,方便共享源資料。...