123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package com.example.sqlrun.fixSql;
- import com.example.sqlrun.myEnum.SpaceEnum;
- import com.shanghaigeography.Util.DateUtils;
- import java.text.ParseException;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.springframework.util.StringUtils;
- /**
- * @ClassName: makeTableSpace
- *
- * @description: TODO
- * @author: sbj
- * @time: 2023/12/5 13:50 @Version: 1.0
- */
- public class MakeTableSpace {
- public static List<Map> makeTableSpaceSql(
- String tableSpaceNamePrefix,
- String tableSpaceFileNamePrefix,
- String tableSpacePath,
- Integer initSize,
- Integer nextSize,
- Integer maxSize,
- Date startDate,
- Integer maxTableSpaceWanted)
- throws ParseException {
- List<Map> tableSpaceSql = new ArrayList<>();
- String startSql = "create tablespace " + "\"" + tableSpaceNamePrefix;
- String datafile = " datafile ";
- if (StringUtils.isEmpty(tableSpacePath) || !StringUtils.hasLength(tableSpacePath)) {
- tableSpacePath = "D:\\app\\Administrator\\dm\\TEST\\" + tableSpaceFileNamePrefix;
- }
- //Date stDate = DateUtils.stringToDate(startDate, "yyyyMM");
- Date maxDate = DateUtils.monthAddNum(startDate, maxTableSpaceWanted);
- while (startDate.compareTo(maxDate) < 0) {
- String yyyyMM = DateUtils.dateToString(startDate, "yyyyMM");
- String targetSql =
- startSql
- + yyyyMM
- + "\""
- + datafile
- + "'"
- + tableSpacePath
- + yyyyMM
- + ".DBF"
- + "'"
- + " size "
- + initSize + "M"
- + " autoextend on next "
- + nextSize + "M"
- + " maxsize "
- + maxSize + "M";
- HashMap<String, Object> hashMap = new HashMap<>();
- hashMap.put(SpaceEnum.TABLESPACE_SQL.getName(),targetSql);
- hashMap.put(SpaceEnum.DATE.getName(), startDate);
- hashMap.put(SpaceEnum.TABLESPACENAME.getName(),tableSpaceNamePrefix + yyyyMM);
- tableSpaceSql.add(hashMap);
- startDate = DateUtils.monthAddNum(startDate, 1);
- }
- // String sql = "create tablespace \"GHJGCHANNEL_TEST\" datafile
- // 'D:\\APP\\ADMINISTRATOR\\ORADATA\\TEST\\TEST1.DBF' size 1M autoextend on next 1M MAXSIZE
- // 10M";
- return tableSpaceSql;
- }
- }
|