db_test

数据库表空间整理

(数据导入方法)

刘凯20101115

经现网查看,现网数据库表空间已全部更换

现网表空间:

TBS_MREAD_HISDAT

TBS_MREAD_HISLOG

TBS_MREAD_DAT

TBS_MREAD_IDX

本地环境表空间:

manager

mread

mread_data

idx

MREAD_HISLOG

MREAD_HISDAT

如今要与现网一致:

manager

mreadTBS_MREAD_DAT

mread_data

idxTBS_MREAD_IDX

MREAD_HISLOGTBS_MREAD_HISLOG

MREAD_HISDATTBS_MREAD_HISDAT

操作步骤:

sys用户dba权限登录数据库

1.备份数据库:

expdpmanager/managerdumpfile=***.dumpdirectory=impdir

2.备份成功后,删除用户

dropusermanagercascade;

3.删除原来表空间

droptablespacexxxincludingcontentsanddatafiles;

4.创建新的表空间

CREATETABLESPACETBS_MREAD_DATDATAFILE'/opt/oracle/oradata/TBS_MREAD_DAT.dbf'SIZE500MREUSEAUTOEXTENDONNEXT10MMAXSIZEUNLIMITEDEXTENTMANAGEMENTLOCAL;

CREATETABLESPACETBS_MREAD_IDXDATAFILE'/opt/oracle/oradata/TBS_MREAD_IDX.dbf'SIZE500MREUSEAUTOEXTENDONNEXT10MMAXSIZEUNLIMITEDEXTENTMANAGEMENTLOCAL;

CREATETABLESPACETBS_MREAD_HISLOGDATAFILE'/opt/oracle/oradata/TBS_MREAD_HISLOG.dbf'SIZE500MREUSEAUTOEXTENDONNEXT10MMAXSIZEUNLIMITEDEXTENTMANAGEMENTLOCAL;

CREATETABLESPACETBS_MREAD_HISDATDATAFILE'/opt/oracle/oradata/TBS_MREAD_HISDAT.dbf'SIZE500MREUSEAUTOEXTENDONNEXT10MMAXSIZEUNLIMITEDEXTENTMANAGEMENTLOCAL;

5.新建用户

createusermanageridentifiedbymanagerdefaulttablespaceTBS_MREAD_DATtemporarytablespacetemp;

6.给新用户赋权限

grantconnect,resource,createpublicdatabaselink,droppublicdatabaselinktomanager;

GRANTUNLIMITEDTABLESPACETOmanagerWITHADMINOPTION;

GRANTSELECTANYTABLETOmanagerWITHADMINOPTION;

GRANTCREATEANYTABLETOmanagerWITHADMINOPTION;

GRANTALTERANYTABLETOmanagerWITHADMINOPTION;

GRANTDROPANYTABLETOmanagerWITHADMINOPTION;

GRANTCREATEANYviewTOmanagerWITHADMINOPTION;

GRANTDROPANYviewTOmanagerWITHADMINOPTION;

grantsysdbatomanager;

grantunlimitedtablespacetomanagerwithadminoption;

7.赋予读取备份文件权限----备份文件“***.dump”在/opt/oracle/expdir目录下

createorreplacedirectoryexpdiras'/opt/oracle/expdir';

grantread,writeondirectoryexpdirtomanager;

8.导入备份的数据库文件

impdpmanager/managerDIRECTORY=expdirDUMPFILE=***.dumpremap_schema=

iread49:managertransform=oid:nremap_tablespace=MANAGER:TBS_MREAD_DAT,MREAD_DATA:

TBS_MREAD_DAT,idx:TBS_MREAD_idx,MREAD:TBS_MREAD_DAT,MREAD_HISDAT:TBS_MREAD_HISDAT,MREAD_HISLOG:TBS_MREAD_HISLOG

说明:DIRECTORY:导入文件的存放目录值为7步中的目录权限名

DUMPFILE:导入文件的文件名

remap_schema:指导导入用户转换,值“导出用户的用户名:导入用户的用户名”

remap_tablespace:表空间转换,值“导出是表存在的表空间:导入后导入的表空间”

相关推荐