hive备份之批量导出表名、建表语句

Hive简介、DDL操作(建表、分区、导入导出等) Hive分析框架 一、Hive简述 Hive 建立在Hadoop文件系统上的数据仓库架构,并对存储在HDFS中的数据进行分析与管理 Hive架构的核心/本质 --将数据通过SQL语句转换成MapReduce操作/转成hdfs操作 数据仓库 --主要用来分析和管理数据,一般是查询操作,需要定期加载和刷新数据 元数据Metastore(表字段定义,属性,存放位置等除本身数据之外的信息)存... 阅读详情

 

如果你需要批量导出hive库中的表结构那么你可以试试

运行以下shell脚本即可将表名导出到tables.txt,建表语句导出到tablesDDL.txt中。


#!/bin/bash

hive -e "use huntor_tmp;show tables;" > tables.txt

echo sleep start

sleep 3

echo sleep end

cat tables.txt |while read eachline

do

hive -e "use huntor_tmp;show create table $eachline" >>tablesDDL.txt

done

脚本中,注意替换的地方:

1、huntor_tmp 为hive 中的库  database (这个是必须替换为自己的库名,注意有两处)

2. 可选则性替换

    ① tables.txt 表名导出保存文件,可以不使用,此处是用来辅助导出表结构的。(如果修改的话有两处需要同时修改)

    ②tablesDDL.txt为建表语句存放文件。可以有修改名称

 

***注意***

 此脚本建表语句是追加形式,所以第二次运行脚本导出时,请将之前生成的交表语句文件删除或清空。

shell脚本导出所有hive库名、hive表名及建表语句 #!/usr/bin/bash # 获取当前脚本所在路径 cur_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd ${cur_dir} # 导出所有hive数据库名 hive -e "show databases;" > ${cur_dir}/all_database.db # 删除导出文件中的警告信息 sed -i '/^WARN:/d' ${cur_dir}/all_database.db # 导出各个hive库下 阅读详情

相关推荐

索引一定能提高性能吗?

上一篇我们介绍了数据库事务的概念和重要性、事务的 ACID 属性,以及并发事务的控制与隔离级别。 今天我们讨论与性能相关的一个重要对象:索引(Index)。你一定听说过:索引可以提高查询的性能。那么,索引的原理是什么呢?有了索引就一定可以查询的更快吗?索引只是为了优化查询速度吗?接下来我们就一一进行解答。 索引的原理 以下是一个简单的查询,查找工号为 5 的员工: SELECT * FROM ...

Tony.Dong的专栏 1472

hive表的建表语句批量获取

有时hive中的一个数据库中有大量的表,对表的建表语句备份就显得重要和麻烦了, 但是是使用hive的命令和shell脚本会很容易实现 1.导出所有表的名称(可以指定数据库名称) hive -e "use dbName;show tables;" > tablesName.txt 2.使用hive内置语法导出hive表的建表语句,这里使用的是一个shell #!/bin/bash ...

需求是无耻的 4754

生成hive建表语句

生成hive建表语句

hive-批量导出表结构,导入表结构

将all_create_table.txt打开,批量将create table 替换成;create table ,如果建的是外部表,就需要将create external table 替换成;(因为导出的每个表后面并没有加分号,导入的数据,每个表的建表语句要以分号结尾)使用use 数据库名,进入某个数据库下,通过show tables可显示该数据库下建了多少张表。执行hive -f all_create_table.txt 即可。将all_create_table.txt放入需要导入的服务器。

weixin_42115825的博客 3102

无痛安装及初始配置 PHP 8.0.3 + Apache 2.4 + MySQL 8.0

PHP 8.0.3 + Apache 2.4 + MySQL 8.0MySQL 8.0.23 安装下载安装配置环境变量初始化MySQLPHP8.0.3 安装下载安装配置环境变量Apache 2.4 安装下载安装启动 MySQL 8.0.23 安装 下载 到官方网站下载:https://dev.mysql.com/downloads/mysql/ 目前的最新版本是MySQL 8.0.23 在Windows上有两种安装方式,一个是zip压缩文件解压然后配置,另一个是图像化界面安装。 这里选择第一种方法安装:

Kuang Da's Blog 6208

自动驾驶开发者必看:nuscenes数据集23类物体标注全解析(附避坑指南)

本文深入解析nuscenes数据集的23类物体标注系统,为自动驾驶开发者提供全面的标注规范解读和实战避坑指南。涵盖多模态数据组织、类别细分规则、属性系统应用技巧以及标注质量验证方法,帮助开发者高效利用这一标杆数据集提升模型性能。

weixin_29041767的博客 256

hive批量导入导出建表语句

导出 #!/bin/bash #数据库名称 database=$1 create_table_sql=$2 #获取hive建表语句 tables=$(hive -e "use $database ; show tables;" > table_names.txt) #指定hive建表所在的数据库 echo "use $database ;" >> $database cat table_names.txt | while read eachline do hive -e

weixin_45682234的博客 1854

实战避坑:在Ubuntu 22.04上配置NVIDIA GPU Direct RDMA时,必须搞清的P2P DMA与IOMMU那些事

本文深入探讨在Ubuntu 22.04上配置NVIDIA GPU Direct RDMA时P2P DMA与IOMMU的关键问题,解析PCIe架构中的地址转换、P2P DMA与标准DMA的区别,以及IOMMU对性能的影响。通过实战案例和调优建议,帮助用户避免常见配置陷阱,提升AI训练集群的数据传输效率。

weixin_33720078的博客 444

HIVE备份--批量导出HIVE建表语句

在HIVE实际工程部署当中,经常会用到一些备份,其中有一项就是如何保存所有HIVE表的建表命令语句。 HIVE本身提供的语句是支持这个,只是需要批量处理。 最基本的两个语句:show tables; show create tables XXX. 建立一个SH文件,来实现批量化处理。如下: #!/bin/bash  hive -e "s

T___Z的博客 4894

Blender.粒子效果

Blender.粒子效果 ✦ shift+A新建一个棱角球,细分(之后要分解成许多小颗粒) ✦ 给球添加粒子系统,这时播放粒子会向下掉,力场权重☛重力☛0后,粒子会在球体周围运动 ✦ shift+A添加一个力场,调整力场强度 ✦如果粒子运动太快,我们可以在输出属性中调整时间重映射的原始值 ✦想让粒子在球周围运动而不是发散出去,在物理属性找到力场设置,调整流的大小 ✦S键将球形缩小到看不见 ✦给粒子变添加立方体的形状,在粒子属性里找到渲染选项,将“光晕”改为“物体”,在实例物体中选择新建的立方

weixin_46385629的博客 6669

描述符链表(Descriptor Chain)是什么?

描述符链表是硬件加速数据传输的核心数据结构,通过链式描述符(包含地址、长度、控制标志等)实现DMA自动批量处理,显著降低CPU负载。其工作原理为:CPU初始化链表后,硬件按序处理每个描述符,完成自动跳转与中断通知。在网卡收包、NVMe存储等场景中应用广泛,优势包括批处理、低延迟和灵活调度。需注意内存对齐、缓存一致性等实现细节,优化手段包括预分配描述符池、环形缓冲区等。该技术是网络/存储领域提升吞吐量的关键方案。

guigenyi的专栏 775

HIVE如何备份建表并批量建表

Linux后台执行hive建表语句导出命令。#一个hql文件,直接执行即可。#导出所有的数据库,并建库。跳过指定库导出表建表语句。

lz_N_one的博客 787

论文阅读:Training language models to follow instructions with human feedback

这篇论文的目标是通过引入一种基于人类反馈的训练方法,来让语言模型更好地按照用户意图行事。这是因为大规模语言模型虽然强大,但有时候会生成不准确、有偏见或者对用户无帮助的内容,这说明它们和用户的需求之间存在一定的“错位”。论文提出了一个新方法,将 GPT-3 进行优化,称为示例数据与监督学习:让人类标注员生成一些正确行为的示例,并使用这些示例来初步优化模型。比较数据与奖励模型:让标注员比较模型生成的多个输出,并将其排序,从中学到模型输出的优劣规则。强化学习优化:基于这些规则,使用强化学习算法进一步优化模型。

CSPhD-winston的博客 1715

批量备份mysql数据库以及将mysql建表语句改为hive建表语句

#!/bin/bash ############功能说明部分####################################### #脚本功能是按照每天对mysql数据库中所有表进行备份,备份文件为:数据库名-表名.sql #实例:backup/2016-08-25/uic-test.sql #测试数据还原实例:mysql -uroot -pprism%didi%dev%135 -h...

ck978105293的博客 1073

MATLAB 控制 E4438C 信号源的研究

通过 MATLAB,我们可以实现对 E4438C 的远程控制,从而实现更高的自动化和可编程性。总结起来,通过使用 MATLAB 和 Instrument Control Toolbox,我们可以轻松地控制 E4438C 信号源并生成各种类型的信号。需要注意的是,以上代码仅为示例,实际应用中可能需要根据具体情况进行更详细的配置和错误处理。此外,MATLAB 还提供了一系列函数和命令,可用于控制 E4438C 信号源的其他功能,如频率调谐、功率设置、调制设置等。您可以根据自己的需求进行相应的配置和控制。

RswtPerl的博客 1013

VS Code下载安装与使用教程

VSCode下载安装与使用教程

weixin_46713695的博客 4万+

jdbc 生成建表语句_记录一次TDH的inceptor导出建表语句和数据

TDH是星环公司的一款大数据组件聚合平台,类似于CDH,但是TDH将一些组件自己做了封装,比如hive重新封装成了inceptor,公司的TDH测试环境要下线,需要备份inceptor中的数据,现在分步做一次记录:1.TDH的各个组件都是安装在docker容器的,命令行无法直接使用,我们需要在客户端界面下载TDH Client包,包取决于你安装的组件,意味着你每次添加或者删除组件都需要重新下载这个...

weixin_26833939的博客 951

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

HIVE 定时备份定时删除全库建表语句

今天又被工头叫去了 因为我们现在系统还是试运行阶段,这个阶段对系统中表的改动是常有的事,包括表结构,列名,属性,HQL脚本等等;为了保证万一有人改错或者误删了表和HQL脚本,无处可恢复,工头要求我写一个可以定时全库备份建表语句的脚本(并且要带有定时删除14天之前的功能)。经过了长久且艰辛得行为斗争之后,这个脚本终于竣工了???????????????? 直接看成果 #!/bin/bash cd /cib/dm/hive_table rm -f tablist* test.fin #use hi

SDKLHKJAS的博客 426

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

大数据 Hadoop下HIVE 定时备份定时删除全库建表语句

hadoop hive 数据库全表建表语句及运行 sql 脚本的定时备份,定时删除14天之前的备份文件 通过 Linux crontab 任务实现定时执行脚本,定时备份及删除

Jackie 的博客 778

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

hive表ddl导出_HIVE备份之批量导出所有的HIVE建表字段

来自:http://blog.youkuaiyun.com/sparkexpert/article/details/52836374# cat exp-tbl.sh#!/bin/bashhive -e "show tables;" > tables.txtcat tables.txt|while read eachlinedohive -e "show create table $eachline" &...

weixin_39907658的博客 293

hive备份建表语句并批量建表

脚本内容如下: #!/bin/bash ##获取数据库 databases=$(hive -e "show databases; exit;") for database in $databases; do #获取hive建表语句 tables=$(hive -e "use $database; show tables;") for table in $tables; do echo "--=========== db: $database

JacksonKing的专栏 1068

hive的数据导入导出,备份恢复

加载HDFS文件数据到表: LOAD DATA INPATH "hdfs_source_path" OVERWRITE INTO TABLE tbl_nm; 加载本地文件数据到表: LOAD DATA LOACL INPATH "loacl_source_path" OVERWRITE INTO TABLE tbl_nm; 将数据导出至本地路径下: insert overwrite...

王义凯 的博客 2785

HIVE备份之批量导出所有的HIVE建表字段

在HIVE实际工程部署当中,经常会用到一些备份,其中有一项就是如何保存所有HIVE表的建表命令语句。 当HIVE中表格特别多的情况下,如何批量进行存储呢。 针对这个问题,网上没有任何相关的资源。 不过从HIVE本身提供的语句是支持这个,只是需要批量处理。 最基本的两个语句:show tables; show create tables XXX. 于

大数据挖掘SparkExpert的博客 8941

备份Hive中的建表语句

需要做数据备份,将hive中的表结构全部导出来: $ cat create_table_statement.sh #/bin/bash db=ods tbls=`hive -e "use $db;show tables"` for tbl in $tbls;do statement=`hive -e "use $db;show create table $tbl"` echo $statement >> $db"_statement.sql" done ...

ChengYanan的博客 794

hive批量导出表结构

hive按user导出全部库的表结果信息,并可以作为表信息迁移使用 #!/bin/bash # 读取表create table # $1 = dim_sycm_offical # $2 = $eachline # $3 = sql file name funCreateTable(){ echo "-- --------------$2" >> create_table_fir...

allen的博客 5643

hive表结构备份 批量备份

hive本身未提供批量导出表格DDL的方法,这里结合脚本语言实现了一版,在此分享,希望对大家能有所帮助。 文章目录一、关键知识点准备1. beeline的几个关键参数2. shell的几个知识点二、实操 - 批量导出DDL1. 编写函数2.执行函数3.函数优化总结 一、关键知识点准备 1. beeline的几个关键参数 beeline \ --showHeader=false \ --outputformat=csv2 \ -e "show databases" # --showHeader 不.

sinat_25207217的博客 2582
上一篇: Hyperledger fabric 1.2 实践:IBM区块链平台- IBM Blockchain Platform: Develop -- Mac OS
下一篇: Hive hdfs Exception:Name node is in safe mode.及Access denied for user root. Superuser privile问题解决方法
grootblockchain
博客等级 码龄11年 55粉丝 101原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值