当前位置:网站首页>金仓数据KingbaseES 批量创建数据库对象
金仓数据KingbaseES 批量创建数据库对象
2022-06-11 10:23:00 【沉舟侧畔千帆过_】
关键字
KingbaseES、procedure、shell
使用方法
1,通过shell脚本文件实现
有时候我们在进行测试的时候需要进行批量的建库以及建表,这时我们可以使用shell脚本实现或者是SQL实现,shell脚本实现时内容如下:
user=system
#用于配置数据库的用户名
port=54587
#用户配置数据库服务的端口
dbname=test
#用于配置需要连接的库
path=/home/tma/gyj/C5oracle/Server/bin/ksql
#配置ksql脚本的绝对路径
for i in {1..2}
do
$path -U$user -p$port -d$dbname -c “create database database$i;"
done
#使用循环创建表\库
create database database$i
此处为了我们方便查看,脚本就设置为执行2次,当然你可以执行XX次,只要修改i的循环范围即可,当然你也可以修改双引号中的内容修改为创建表,即可批量创建表,执行脚本时,创建的对象就变为了创建表,这里我们将双引号中内容进行修改后,分别执行,执行结果如下:


2,通过SQL查询语句实现循环创建表
之前我们通过shell脚本实现了创建表,同理我们也可以通过SQL编辑器实现
批量创建表。代码如下:
DECLARE
i int := 1;
BEGIN
FOR a in 1..2 LOOP
EXECUTE IMMEDIATE 'CREATE TABLE test_tasa_'|| i ||' (a int PRIMARY KEY,b varchar(20) NOT NULL,c DATE DEFAULT sysdate,d int UNIQUE)';
i := i+1;
END LOOP;
END;
执行结果如下:

边栏推荐
- 数据库设计及范式讲解
- Windows 安装MySQL5.7 以上的版本(压缩包形式安装)
- How much do you know about software compatibility testing? How to select a software compatibility testing organization?
- 转载:LinearLayout+Fragment实现下导航栏效果
- No more! The entry byte beat for a week and ran decisively.
- C语言课程设计题目
- ZigBee模块无线传输星形拓扑组网结构简介
- Secret behind the chart | explanation of technical indicators: tangqi'an channel
- 详述用网络分析仪测量DC-DC和PDN
- Correct opening method of RPC | understand go native net/rpc package
猜你喜欢

MySQL basic learning notes 03

Some code fragments of a universal and confession wall system developed by PHP

安全相关网站推荐

DENISON液压泵用什么液压油?有哪些要求

Mysql--事务

BCGControlBar库专业版,完整记录的MFC扩展类

CISP-PTE XSS基础

Windows 安装MySQL5.7 以上的版本(压缩包形式安装)

Detail measurement of DC-DC and PDN with network analyzer

Cisp-pte XSS Foundation
随机推荐
为什么DDRx的电源设计时需要VTT电源
Tree topology networking structure of ZigBee module communication protocol
手写代码call,apply,bind
puppeteer入门之 BrowserFetcher 类
Tiktok encounters cultural conflict in the UK, and many employees leave in a short time
科技云报道:Web3.0浪潮下的隐私计算
有哪些ABAP关键字和语法,到了ABAP云环境上就没办法用了?
Wuenda machine learning course - week 7
Technology cloud report: privacy computing under the wave of Web3.0
[Bert]: Calculation of last ave state when training tasks with similar Bert semantics
Q1营收超预期,满帮为何赢得逆风增长?
Some code fragments of a universal and confession wall system developed by PHP
Browser class for getting started with puppeter
NGUI,聊天滚动框,UI TextList
ZigBee模块无线传输星形拓扑组网结构简介
Database design and paradigm explanation
MySQL基础篇常用约束总结上篇
Excellent test engineer must have 4 safety test methods!
What is the SOA or ASO of MOSFET?
NGUI,背包拖拽,以及随机克隆图片知识点