批量创建表空间数据文件(DM8:达梦数据库)

DM8:达梦数据库 - - 批量创建表空间数据文件

  • 环境介绍
  • [1 批量创建表空间SQL](#1 批量创建表空间SQL)
  • [2 达梦数据库学习使用列表](#2 达梦数据库学习使用列表)

环境介绍

  • 在某些场景(分区表子表)需要批量创建表空间,给不同的表使用,以下代码是批量创建表空间的SQL语句;

1 批量创建表空间SQL

sql 复制代码
--创建 24个数据表空间,每个表空间有3个数据文件,一个数据文件初始化为128M,每次扩展1024M,最大扩展到 409600M

DECLARE
    TBS_NAME VARCHAR :='TBS_DATA_';		--数据表空间名称
    --TBS_NAME VARCHAR :='TBS_INDEX_';	--索引表空间名称

    TBS_COUNT        INT :=24;	--表空间数量
    TBS_FILE_COUNT   INT :=3;	--表空间数据文件数量
    TBS_FILE_F       INT;
    
    TBS_EXTENT_BEGIN VARCHAR;
    TBS_EXTENT_TEMP  VARCHAR;
    TBS_EXTENT_TEMP2 VARCHAR;
    TBS_EXTENT_END   VARCHAR;
    TBS_EXTENT_ALL   VARCHAR;
BEGIN
    FOR I IN 1..TBS_COUNT 
    LOOP
        TBS_EXTENT_BEGIN :='create tablespace "'||TBS_NAME||I||'" datafile '''||TBS_NAME||I||'_FILE_1.DBF'' size 128 autoextend on next 1024 maxsize 409600';
        TBS_EXTENT_TEMP  :='';
        FOR TBS_FILE_F IN 2..TBS_FILE_COUNT 
        LOOP
            TBS_EXTENT_TEMP2    := ','''||TBS_NAME||I||'_FILE_'||TBS_FILE_F||'.DBF'' size 128 autoextend on next 1024 maxsize 409600';
            TBS_EXTENT_TEMP := TBS_EXTENT_TEMP||TBS_EXTENT_TEMP2;
        END LOOP;
        TBS_EXTENT_END := ' CACHE = NORMAL;';
        TBS_EXTENT_ALL :=TBS_EXTENT_BEGIN||TBS_EXTENT_TEMP||TBS_EXTENT_END;
        PRINT (TBS_EXTENT_ALL);
        EXECUTE IMMEDIATE TBS_EXTENT_ALL;
    END LOOP;
END;
-- 生成的创建表空间 SQL
/*
create tablespace "TBS_DATA_1" datafile 'TBS_DATA_1_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_1_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_1_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_2" datafile 'TBS_DATA_2_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_2_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_2_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_3" datafile 'TBS_DATA_3_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_3_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_3_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_4" datafile 'TBS_DATA_4_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_4_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_4_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_5" datafile 'TBS_DATA_5_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_5_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_5_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_6" datafile 'TBS_DATA_6_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_6_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_6_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_7" datafile 'TBS_DATA_7_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_7_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_7_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_8" datafile 'TBS_DATA_8_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_8_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_8_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_9" datafile 'TBS_DATA_9_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_9_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_9_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_10" datafile 'TBS_DATA_10_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_10_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_10_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_11" datafile 'TBS_DATA_11_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_11_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_11_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_12" datafile 'TBS_DATA_12_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_12_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_12_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_13" datafile 'TBS_DATA_13_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_13_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_13_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_14" datafile 'TBS_DATA_14_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_14_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_14_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_15" datafile 'TBS_DATA_15_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_15_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_15_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_16" datafile 'TBS_DATA_16_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_16_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_16_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_17" datafile 'TBS_DATA_17_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_17_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_17_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_18" datafile 'TBS_DATA_18_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_18_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_18_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_19" datafile 'TBS_DATA_19_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_19_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_19_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_20" datafile 'TBS_DATA_20_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_20_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_20_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_21" datafile 'TBS_DATA_21_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_21_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_21_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_22" datafile 'TBS_DATA_22_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_22_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_22_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_23" datafile 'TBS_DATA_23_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_23_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_23_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;
create tablespace "TBS_DATA_24" datafile 'TBS_DATA_24_FILE_1.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_24_FILE_2.DBF' size 128 autoextend on next 1024 maxsize 409600,'TBS_DATA_24_FILE_3.DBF' size 128 autoextend on next 1024 maxsize 409600 CACHE = NORMAL;

*/

2 达梦数据库学习使用列表

相关推荐
The_Ticker36 分钟前
CFD平台如何接入实时行情源
java·大数据·数据库·人工智能·算法·区块链·软件工程
Elastic 中国社区官方博客42 分钟前
Elasticsearch 开放推理 API 增加了对 IBM watsonx.ai Slate 嵌入模型的支持
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
企鹅侠客1 小时前
ETCD调优
数据库·etcd
Json_181790144801 小时前
电商拍立淘按图搜索API接口系列,文档说明参考
前端·数据库
煎饼小狗1 小时前
Redis五大基本类型——Zset有序集合命令详解(命令用法详解+思维导图详解)
数据库·redis·缓存
永乐春秋1 小时前
WEB-通用漏洞&SQL注入&CTF&二次&堆叠&DNS带外
数据库·sql
打鱼又晒网2 小时前
【MySQL】数据库精细化讲解:内置函数知识穿透与深度学习解析
数据库·mysql
王小小鸭2 小时前
【开发小技巧11】用经典报表实现badge list效果,根据回显内容用颜色加以区分
oracle·oracle apex
大白要努力!2 小时前
android 使用SQLiteOpenHelper 如何优化数据库的性能
android·数据库·oracle
tatasix3 小时前
MySQL UPDATE语句执行链路解析
数据库·mysql