31-数据仓库与Apache Hive-Insert插入数据

1.Insert语法功能

复制代码
 1.1 暴力方式上传
 1.2 使用 hadoop fs -put 方式上传 
 1.3. 使用load 加载数据 !!! 

hive 官方推荐第三种方式 !!!

复制代码
	基于上图  在hive中 insert into table values... 这样的语法禁止使用!
	推荐使用:
	INSERT INTO TABLE tablename select_statement1 FROM from_statement;
  insert +select 表示:
    将后面的查询结果作为内容插入到指定的表中.
    注意事项:
     1.需要保证查询结果列的数目和需要插入的数据表的列的数据一致
     2.如果查询出来的数据类型和拆入表的数据类型不一致,将会进行转换,但是不能保证转换一定成功[ string  int ],转换失败的数据会为null <注意数据类型要一致>
     INSERT INTO TABLE tablename select_statement1 FROM from_statement;
bash 复制代码
-- 2025年08月08日
show databases ;
show schemas ;

show tables ;
--新建数据库
create  database shaonainai;

-- 用一下库
use shaonainai;

-- 本地上传表
create table student_local(
  num int,
  name string,
  sex string,
  age int ,
  dept string

) row format delimited
fields terminated by ',';


create table student_hdfs(
  num int,
  name string,
  sex string,
  age int ,
  dept string

) row format delimited
fields terminated by ',';




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


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


select * from student_hdfs;

-- 讲解  INSERT INTO TABLE tablename select_statement1 FROM from_statement;

create table student(
  num int,
  name string,
  sex string,
  age int ,
  dept string

) row format delimited
fields terminated by ',';

-- 加载数据
load data local inpath '/export/data/hivedata/students.txt' into table shaonainai.student;

select  * from student;

--  新建两列的表 等待数据插入
create table student_from_insert(
  num int,
  name string
) ;


select * from student_from_insert;
-- 语法   INSERT INTO TABLE 要插入数据的表 select 列名1,列名2... FROM 有数据的表;
 INSERT INTO TABLE student_from_insert select num,name  FROM student;

select * from student_from_insert;
相关推荐
前端 贾公子17 小时前
小程序蓝牙打印探索与实践(下)
小程序·apache
白日与明月18 小时前
Hive子查询中的ORDER BY陷阱:为什么排序“消失”了?
数据仓库·hive·hadoop
DolphinScheduler社区19 小时前
Apache DolphinScheduler 3.4.2 正式发布!新增 Amazon EMR Serverless 插件,增强监控与补数据能力
大数据·云原生·serverless·apache·海豚调度·版本发版
前端 贾公子19 小时前
小程序蓝牙打印探索与实践(中)
apache
SeaTunnel19 小时前
87 个 PR 迭代复盘|Apache SeaTunnel 5 月版本重点更新解读
大数据·数据库·开源·apache·seatunnel
DolphinScheduler社区19 小时前
实战演示 | 基于 Apache DolphinScheduler 与 Apache SeaTunnel 实现 MySQL 到 Doris 离线定时增量同步
数据库·mysql·开源·apache·海豚调度·大数据工作流调度
chéng ௹19 小时前
uniapp封装火山引擎 DataRangers 埋点 SDK
uni-app·apache·火山引擎
阿坤带你走近大数据20 小时前
Apache Hop的详细介绍
apache
isNotNullX2 天前
企业数据中台建设,ETL工具选错了会踩哪些坑?
数据仓库·etl·原型模式
SelectDB技术团队2 天前
预约发布会|核心产品力首发,如何构建面向 Agent 时代的企业级数据引擎
数据库·数据仓库·人工智能·数据分析·可观测·apache doris·selectdb