30-Hive SQL-DML-Load加载数据

1.上传数据

复制代码
1.1 暴力方式

 1.2命令行方式 
 首先在 /export/data 下面创建  文件件 hivedata
 上传记事本文件到 hivedata下面 
 使用cd 命令切换到 /export/data/hivedata 下面
bash 复制代码
[root@node1 hivedata]# hadoop fs -put team_ace_player.txt /user/hive/warehouse/liushao.db/t_team_ace_player

2.Hive中的show语法

复制代码
2.1显示当前数据库下面的表
show tables ;

 show tables [in database_name];

3. Load命令 加载数据

复制代码
load data [local] inpath 'filepath' into table tablename;

filepath 等待移动的数据的路径 
相对路径 project/data1
绝对路径 /user/hive/project/data1
完整的路径: hdfs://node1:9000/user/hive/project/data1
完整路径 == schema的完整路径 

local
本地文件相对路径 
 file://user/hive/project/data1
复制代码
本地文件系统指的是Hiveserver2服务所在机器的本地Linux文件系统,不是Hive客户端所在的本地文件系统。
bash 复制代码
--  4.使用Load加载数据
-- 4.1 根据students.txt创建数据库表
-- 95001,李勇,男,20,CS
create  table liushao.student_local(
    num int comment '编号',
    name string comment '姓名',
    sex string comment '性别',
    age int comment '年龄',
    dept string comment '部门'
)
row format delimited
fields terminated by ',';

use liushao;
--  使用load装载数据
load data local inpath '/export/data/hivedata/students.txt' into table student_local;


select * from student_local;

select * from luoshao.student_local;

use luoshao;

load data local inpath '/export/data/hivedata/students.txt' into table student_local;

use liushao;


create  table liushao.student_hdfs(
    num int comment '编号',
    name string comment '姓名',
    sex string comment '性别',
    age int comment '年龄',
    dept string comment '部门'
)
row format delimited
fields terminated by ',';


load data  inpath '/students.txt' into table student_hdfs;

select * from liushao.student_hdfs;
相关推荐
SeaTunnel9 小时前
Apache SeaTunnel 2025 案例精选重磅发布!
大数据·开源·apache·seatunnel·案例
Justice Young10 小时前
Hive第四章:HIVE Operators and Functions
大数据·数据仓库·hive·hadoop
LF3_11 小时前
hive,Relative path in absolute URI: ${system:user.name%7D 解决
数据仓库·hive·hadoop
德彪稳坐倒骑驴13 小时前
Hive SQL常遗忘的命令
hive·hadoop·sql
麦兜*13 小时前
Spring Boot 整合 Apache Doris:实现海量数据实时OLAP分析实战
大数据·spring boot·后端·spring·apache
Justice Young13 小时前
Hive第六章:Hive Optimization and Miscellaneous
数据仓库·hive·hadoop
Justice Young14 小时前
Hive第五章:Integeration with HBase
大数据·数据仓库·hive·hbase
Justice Young14 小时前
Hive第三章:HQL的使用
大数据·数据仓库·hive·hadoop
云边有个稻草人15 小时前
大数据时代下的时序数据库选型指南:为何Apache IoTDB成为最优解
大数据·apache·时序数据库·apache iotdb
zgl_200537791 天前
ZGLanguage 解析SQL数据血缘 之 标识提取SQL语句中的目标表
java·大数据·数据库·数据仓库·hadoop·sql·源代码管理