1、以sys用户登陆
sqlplus sys/sys as sysdba
2、创建名为dgpdg的表空间
create tablespace dgpdg
logging
datafile 'D:appx5456oradataorcldgpdg_01.dbf'
size 1500m
autoextend on
next 100m maxsize 10000m
extent management local;
3、创建用户,绑定表空间dgpdg
create user dgpdgltfirst identified by 5456 DEFAULT TABLESPACE dgpdg;
4、为用户授权
GRANT
CREATE SESSION, CREATE ANY TABLE, CREATE ANY VIEW ,CREATE ANY INDEX, CREATE ANY sequence,CREATE ANY PROCEDURE,
ALTER ANY TABLE, ALTER ANY sequence,ALTER ANY PROCEDURE,
DROP ANY TABLE, DROP ANY sequence,DROP ANY VIEW, DROP ANY INDEX, DROP ANY PROCEDURE,
SELECT ANY TABLE, INSERT ANY TABLE, UPDATE ANY TABLE, DELETE ANY TABLE
TO dgpdgltfirst;
上面的授权太多,修改为:
grant connect,resource to dgpdgltfirst;
5、退出sql*plus,使用cmd命令进行导入dmp文件
imp dgpdgltfirst/5456@127.0.0.1/orcl file="D:dgpdgltfirst20171025.dmp" log="D:dgpdgltfirst20171025.log" full=y ignore=y statistics=none
异常1:
IMP-00013: 只有 DBA 才能导入由其他 DBA 导出的文件
IMP-00000:为成功终止导入
原因:
导出数据的用户拥有DBA权限,而导入的用户没有这个权限;所以我们要给他添加dba这个权限
解决方案:
用sys 登录,给用户授权grant dba to 用户名;
示例:grant dba to dgpdgltfirst;
异常2:
解决方案:
在exp或imp时加上一个参数来禁用统计信息的导出/导入:
statistics=none
删除用户
grant connect,resource to dgpdgltfirst;