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;
相关推荐
XMYX-03 小时前
解决 Apache/WAF SSL 证书链不完整导致的 PKIX path building failed 问题
网络协议·apache·ssl
IT·陈寒4 小时前
怎么这么多 StringUtils —— Apache、Spring、Hutool 全面对比
java·spring·apache
喂完待续1 天前
【Big Data】云原生与AI时代的存储基石 Apache Ozone 的技术演进路径
云原生·架构·apache·big data·序列晋升
todoitbo2 天前
时序数据库选型指南:Apache IoTDB快速部署与实战应用
apache·时序数据库·iotdb
IDOlaoluo2 天前
apache-jmeter-5.1.1安装部署与使用教程(小白一看就会)
jmeter·apache
倔强的石头1062 天前
时序数据库选型指南:为何Apache IoTDB成为工业物联网首选
apache·时序数据库·iotdb
wei_shuo2 天前
物联网时序数据存储方案:Apache IoTDB 集群部署全流程 + TimechoDB 优势解读
物联网·apache·iotdb
sanggou3 天前
Apache Doris:重塑湖仓一体架构的高效计算引擎
架构·数据分析·apache
KANGBboy3 天前
hive udf 执行一次调用多次问题
数据仓库·hive·hadoop
C-20023 天前
Apache 的安装及基本使用
apache