1 数据导出
exp user/pwd@srcip:1521/orcl file=path/name.dmp owner=name
2 目标库新建用户并赋权限
①sqlplus / as sysdba // 进入目标库dba账户
②create user name identified by name default tablespace users; // 新建用户并配置默认表空间
③grant connect,resource,dba to ittbank ; // 赋予用户权限
3 把dmp文件从源库复制到目标库
scp name.tmp user@dstip:path
4 更新目标库的字符集,和源库字符集保持一致
①select * from nls_database_parameters ORDER BY 1; // 查询源库和目标库的字符集信息
②ALTER SYSTEM ENABLE RESTRICTED SESSION; // 把当前连接改为restricted模式
③断开其余客户端连接
④ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;
⑤ALTER DATABASE NATIONAL CHARACTER SET INTERNAL_USE UTF8;
5 数据导入
imp user/pwd@dstip:1521/orcl file=path/name.dmp full=y ignore=y
发现表空间不够用的解决步骤:
①查看表空间使用情况
select
a.tablespace_name,
total,
free,
total-free as used,
substr(free/total * 100, 1, 5) as "FREE%",
substr((total - free)/total * 100, 1, 5) as "USED%"
from
(select tablespace_name, sum(bytes)/1024/1024 as total from dba_data_files group by tablespace_name) a,
(select tablespace_name, sum(bytes)/1024/1024 as free from dba_free_space group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by a.tablespace_name;
②扩容表空间
alter tablespace USERS add datafile '/home/oracle/app/oracle/oradata/ORCL/users01.dbf' size 31g autoextend on next 31g;
发现磁盘空间不够用解决方案:
①清理Oracle的归档日志:
// 进入rman
rman
// 连接本地oracle db
connect target /
// 删除七天以前的归档日志
DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-7';
// 强制删除所有归档日志
delete force archivelog all;
②关闭Oracle的归档模式
// 进入sys管理员
sqlplus / as sysdba
// 关闭数据库
shutdown immediate;
// 启动mount模式
startup mount;
// 把数据库改成非归档模式
alter database NOARCHIVELOG;
// 启动数据库
alter database open;