批量创建表空间数据文件(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 达梦数据库学习使用列表

相关推荐
Mephisto.java2 分钟前
【大数据学习 | kafka高级部分】kafka的kraft集群
大数据·sql·oracle·kafka·json·hbase
Mephisto.java4 分钟前
【大数据学习 | kafka高级部分】kafka的文件存储原理
大数据·sql·oracle·kafka·json
十叶知秋34 分钟前
【jmeter】jmeter的线程组功能的详细介绍
数据库·jmeter·性能测试
瓜牛_gn2 小时前
mysql特性
数据库·mysql
奶糖趣多多3 小时前
Redis知识点
数据库·redis·缓存
CoderIsArt4 小时前
Redis的三种模式:主从模式,哨兵与集群模式
数据库·redis·缓存
师太,答应老衲吧6 小时前
SQL实战训练之,力扣:2020. 无流量的帐户数(递归)
数据库·sql·leetcode
Channing Lewis7 小时前
salesforce case可以新建一个roll up 字段,统计出这个case下的email数量吗
数据库·salesforce
毕业设计制作和分享9 小时前
ssm《数据库系统原理》课程平台的设计与实现+vue
前端·数据库·vue.js·oracle·mybatis
ketil279 小时前
Redis - String 字符串
数据库·redis·缓存