怎样修改分区表的分区所在的表空间

怎样修改分区表的分区所在的表空间,第1张

你修改这个干什么?会把硬盘搞瘫痪。
分区表一般位于硬盘某柱面的0磁头1扇区。而第1个分区表(也即主分区表)总是位于(0柱面,0磁头,1扇区),分区表只有64个字节
你如果要分区,重新分区就是了,

每个分区的盘符和卷标都是可以修改的。

修改盘符:在磁盘管理器中右击分区,然后选“更改驱动器号和路径”

修改卷标: 在资源管理中右击分区,然后选择“重命名”

1、用U大师启动盘启动后进入U大师WIN8pe
2、运行桌面上的分区工具DiskGenius
3、我们看到分盘卷有ESP跟MSR。
4、删除所有分区卷。
5、全部删除后,保存更改。如下图所示:
6、打开硬盘,点击“转换分区表类型为MBR格式”,如下图所示:
7、在d出的提示窗口中选择“确定”。注:一般GUI分区表格式支持超过2TB以上的硬盘分区,而MBR分区表类型只支持2TB以下的硬盘。
8、转换MBR成功后,选择快速分区,根据要求创建自己的分区。选择完成后,点击确定开始分区,如下图所示:
9、分区开始后,会出现格式化盘符的提示窗口,等待完成。退出DiskGenius软件。

1创建分区表,INCLUSIVE(包含),exclusive(不包含)
CREATE TABLE "MABAS""BAS_MID_TRANS_LIST_CK_BAK" ( "REPORT_DATE" DATE, "MA_ACCT_NO" VARCHAR(100), "TRANS_DATE" DATE, "ORG_UNIT_ID" VARCHAR(15), "ORG_PROD_ID" VARCHAR(15), "CURR_CD" VARCHAR(15), "ACCT_NO" VARCHAR(15), "TRANS_NUM" VARCHAR(15), "TRANS_NO" VARCHAR(15), "TRANS_DIF" VARCHAR(15), "DEPOSIT_CHAR" VARCHAR(15), "DEPOSIT_BAL" DECIMAL(18,2), "TRANS_AMT" DECIMAL(18,2), "TRANS_TYPE" CHARACTER(1), "FLG" CHARACTER(1), "RATE" DECIMAL(18,6), "TRXMEM" DECIMAL(4,0)) IN "MA_DATA" INDEX IN "MA_INDEX" PARTITION BY RANGE ( "REPORT_DATE" NULLS LAST ) ( PARTITION PART0 STARTING '2010-12-10' INCLUSIVE ENDING '2010-12-20' INCLUSIVE ) ;
ALTER TABLE "MABAS""BAS_MID_TRANS_LIST_CK_BAK" DATA CAPTURE NONE LOCKSIZE ROW APPEND OFF NOT VOLATILE;
COMMENT ON TABLE "MABAS""BAS_MID_TRANS_LIST_CK_BAK" IS '活期交易明细表';
COMMENT ON "MABAS""BAS_MID_TRANS_LIST_CK_BAK" ( "REPORT_DATE" IS '数据日期', "MA_ACCT_NO" IS '管会账号', "TRANS_DATE" IS '营业日期', "ORG_UNIT_ID" IS '行所号', "ORG_PROD_ID" IS '业务品种 ', "CURR_CD" IS '币别', "ACCT_NO" IS '帐号', "TRANS_NUM" IS '交易序号', "TRANS_NO" IS '交易代号', "TRANS_DIF" IS '交易区别', "DEPOSIT_CHAR" IS '存款性质 ', "DEPOSIT_BAL" IS '存款余额', "TRANS_AMT" IS '交易金额', "TRANS_TYPE" IS '交易别', "FLG" IS '连动标志', "RATE" IS '汇率' );
GRANT CONTROL ON TABLE "MABAS""BAS_MID_TRANS_LIST_CK_BAK" TO USER "DB2INST2";
GRANT SELECT, INSERT, UPDATE, ALTER, DELETE, INDEX, REFERENCES ON TABLE "MABAS""BAS_MID_TRANS_LIST_CK_BAK" TO USER "DB2INST2" WITH GRANT OPTION;
GRANT SELECT, INSERT, UPDATE, ALTER, DELETE, INDEX, REFERENCES ON TABLE "MABAS""BAS_MID_TRANS_LIST_CK_BAK" TO USER "DB2INST2" WITH GRANT OPTION;
GRANT SELECT, INSERT, UPDATE, ALTER, DELETE, INDEX, REFERENCES ON TABLE "MABAS""BAS_MID_TRANS_LIST_CK_BAK" TO USER "MAPUB" WITH GRANT OPTION;
2增加分区,注意这里的INCLUSIVE,exclusive,这时只有2011-01-31的数据可以进行insert
alter table MABASBAS_MID_TRANS_LIST_CK_BAK add partition LIST_CK_bak0131 STARTING '2011-01-31' INCLUSIVE ENDING '2011-02-01' exclusive
3insert 数据
insert into MABASBAS_MID_TRANS_LIST_CK_BAK select from MABASBAS_MID_TRANS_LIST_CK where report_date=date('2011-01-31');
4转移分区到临里表
alter table MABASBAS_MID_TRANS_LIST_CK_BAK detach partition LIST_CK_bak0131 into MABASBAS_MID_TRANS_LIST_CK_BAK1
5删除生成的分区迁移表,注意这时分区表的分区(LIST_CK_bak0131)己经不存在了,如果要insert必须新增该分区
drop table MABASBAS_MID_TRANS_LIST_CK_BAK1
以下为应用写的shell脚本,并参照syscatdatapartitions 进行判断,如果有则删除分区,否则进行新建,以下为具体的脚本。
/home/odSUSEr1/profile#配置文件SYSNAME=GDBMAMADS_HOME=/home/odsuser1/gdbma/etl#DS ConfigDSConfigFile=$MADS_HOME/dsconfig_gdbma#MARPT ETL2数据库#DB信息DBNAME=`awk 'FS="=" {if ($0~/^MABASDBName/) print $2}' $DSConfigFile`DBUSR=`awk 'FS="=" {if ($0~/^MABASDBUser/) print $2}' $DSConfigFile`DBPWD=`awk 'FS="=" {if ($0~/^MABASDBPassword/) print $2}' $DSConfigFile`DBSCHEMA=`awk 'FS="=" {if ($0~/^MABASDBSchema/) print $2}' $DSConfigFile`DBPWD=`$MADS_HOME/Encrypt/discryptsh $DBPWD`dbname=$DBNAMEuser=$DBUSRpasswd=$DBPWD#连接数据库db2 connect to $DBNAME user $DBUSR using $DBPWD >/dev/nulldb2 set schema=$DBSCHEMA;#传递参数JOB_NAME=$1DELETE_DATE=$2#DELETE_DBSCHEMA=$1#DELETE_TAB=$2#DELETE_COL=$3#DELETE_TYPE=$4#DELETE_DATE=$5#DELETE_VALUE=$6
delete_tab="select SCH_NAME,TAB_NAME,IF_PARTITION,TAB_DATE,DEL_VALUE from mabass_job_info_m t where JOB_NAME = '"$JOB_NAME"' "DEL_DATA=`db2 -t "$delete_tab"`if [ $ -ne 0 ]thenecho "$SDATA"fiecho "$DEL_DATA" | sed -e '4,/^$/!d;/^$/d'|#循环读取job,然后调度while read SCH_NAME TAB_NAME IF_PARTITION TAB_DATE DEL_VALUEdo#判断删除方式#分区字段拼写if [ "$IF_PARTITION" = 'Y' ] then #分区进行拼写 partiton_name=`db2 -tx "select upper('p'||replace(varchar(date('"$DELETE_DATE"')),'-','')) from sysibmsysdummy1 "` tmp_tab=`db2 -tx "select upper('tmp'||substr(replace(replace(varchar(current timestamp),'-',''),'',''),5,10)) from sysibmsysdummy1 "` #判断分区是否存在 vi_result=`db2 -tx "select count() from syscatdatapartitions t where tabschema = upper('"$SCH_NAME"') and tabname = upper('"$TAB_NAME"') and datapartitionname=upper('"$partiton_name"') "` #对分区进行 *** 作 if [ "$DEL_VALUE" = '-' ] then #判断分区是否存在 if [ $vi_result -ne 0 ] then #进行分区数据到临时表 alter_parition=`db2 -tx "alter table $SCH_NAME$TAB_NAME detach partition $partiton_name into $SCH_NAME$tmp_tab"` #删除临时表 drop_tmp=`db2 -tx "drop table $SCH_NAME$tmp_tab"` #分区结束 partition_end=`db2 -tx "select varchar(date('"$DELETE_DATE"') +1 days) from sysibmsysdummy1"` #增加分区 add_partition=`db2 -tx "alter table $SCH_NAME$TAB_NAME add partition $partiton_name STARTING '"$DELETE_DATE"' INCLUSIVE ENDING '"$partition_end"' exclusive "` else #分区结束 partition_end=`db2 -tx "select varchar(date('"$DELETE_DATE"') +1 days) from sysibmsysdummy1"` #增加分区 add_partition=`db2 -tx "alter table $SCH_NAME$TAB_NAME add partition $partiton_name STARTING '"$DELETE_DATE"' INCLUSIVE ENDING '"$partition_end"' exclusive "` fi else if [ $vi_result -ne 0 ] then #进行分区数据到临时表 drop_parition=`db2 -tx "alter table $SCH_NAME$TAB_NAME detach partition $partiton_name into $SCH_NAME$tmp_tab "` #备份临时表中不属于该条件的数据 delete_tab_date=`db2 -tx "delete from $SCH_NAME$tmp_tab where "$DEL_VALUE" "` #分区结束 partition_end=`db2 -tx "select varchar(date('"$DELETE_DATE"') +1 days) from sysibmsysdummy1"` #增加分区 add_partition=`db2 -tx "alter table $SCH_NAME$TAB_NAME add partition $partiton_name STARTING '"$DELETE_DATE"' INCLUSIVE ENDING '"$partition_end"' exclusive "` #insert 不符合删除条件的数据 insert_date=`db2 -tx "insert into $SCH_NAME$TAB_NAME select from $SCH_NAME$tmp_tab "` else #分区结束 partition_end=`db2 -tx "select varchar(date('"$DELETE_DATE"') +1 days) from sysibmsysdummy1"` #增加分区 add_partition=`db2 -tx "alter table $SCH_NAME$TAB_NAME add partition $partiton_name STARTING '"$DELETE_DATE"' INCLUSIVE ENDING '"$partition_end"' exclusive "` fi fielse #直接删除表 if [ "$DEL_VALUE" = "-" ] then delete_tab_data=`db2 -tx "delete from $SCH_NAME$TAB_NAME where date("$TAB_DATE") = DATE('"$DELETE_DATE"') "` else delete_tab_data=`db2 -tx "delete from $SCH_NAME$TAB_NAME where date("$TAB_DATE") = DATE('"$DELETE_DATE"') and $DEL_VALUE "` fifidone

重建分区步骤:
1、将制作好的u深度u盘启动盘插入电脑接口,开机按快捷键进入主菜单界面,选择“02U深度WIN8 PE标准版(新机器)”,
2、进入win8pe系统后,双击桌面上“DiskGenius分区工具”图标
3、在d出分区工具Diskgenius工具中,依次打开“工具-搜索已丢失分区(重建分区表)(L)”
4、在d出的搜索丢失分区的窗口中选择搜索范围“整个硬盘”,点击“开始搜索”按钮即可
5、等会进入搜索分区任务,直接点击“保留”按键进行下一步 *** 作,搜到逻辑分区会d出提示窗,再次点击“保留”按键
6、搜索完成后,系统将会d出提示框,直接点击“确定”即可


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/13332057.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-16
下一篇 2023-07-16

发表评论

登录后才能评论

评论列表(0条)

保存