打开sqlplus
创建用户:create user mingzi identified by 123456;
用户授权:grant connect, resource,dba to mingzi;
导入:imp mingzi/123456@orcl file=d:\file.dmp full=y
(其中mingzi是你的用户名,123456是密码,@是必须要写的命令,orcl是你的数据库实例,d:\file.dmp是你的导入的数据库文件,full=y是必须要写的参数
三种登录方法
方式1:
sqlplus / as sysdba
方式2:
sqlplus username/password@ip:port/sid
sqlplus username/password@orcl – 简写(前提:配置了 TNS),以下同
方式3:(推荐)
sqlplus /nolog
conn username/password@ip:port/sid
IMP导入的时候 :如果已经存在此表, 会告诉你无法创建此表,因为表已经存在。同时使用参数 full=y ignore=y 那就是全部导入,把dmp里的所有数据插入到表里面。换句话说会有重复,如果该表有主键,重复的会因为违反约束,导入不成功,但不重复的能够进去,这种情况是追加覆盖进去了。
数据备份,使用命令:
exp user/user file=d:\user.dmp full=y
恢复时,使用命令:
imp user/user FILE=d:\user.dmp fromuser=user touser=user full=y ignore=y
IMPDP导入的时候 :用参数table_exists_action=replace 进行删除后覆盖;
table_exists_action选项:{skip 是如果已存在表,则跳过并处理下一个对象;append是为表增加数据;truncate是截断表,然后为其增加新数据;replace是删除已存在表,重新建表并追加数据}
数据备份,使用命令:
expdp user/user directory=dump_dir dumpfile=schema.dmp logfile=schema.log schemas=user job_name=exp_user_schema
恢复时,使用命令:impdp user/user directory=dump_dir dumpfile=schema.dmp logfile=schema.log table_exists_action=replace schemas=user content=all job_name=imp_schema