oracle 导入导出数据

数据导出:

1 将数据库TEST完全导出,用户名system 密码manager 导出到D:/daochu.dmp中  
    exp system/manager@TEST file=d:/daochu.dmp full=y 

(远程:exp jeesite/jeesite@210.123.134.13:1521/ORCL file=d:/daochu.dmp owner=(jeesite))
2 将数据库中system用户与sys用户的表导出   
exp system/manager@TEST file=d:/daochu.dmp owner=(system,sys) 
3 将数据库中的表inner_notify、notify_staff_relat导出    
exp aichannel/aichannel@TESTDB2 file= d:/data/newsmgnt.dmp tables=(inner_notify,notify_staff_relat)   
4 将数据库中的表table1中的字段filed1以"00"打头的数据导出  
 exp system/manager@TEST file=d:/daochu.dmp tables=(table1) query=/" where filed1 like '00%'/"    
上面是常用的导出,对于压缩,既用winzip把dmp文件可以很好的压缩。

也可以在上面命令后面 加上 compress=y 来实现。

数据的导入

以用户名和密码创建一个用户并赋予DBA权限

cmd命令行导入dmp(确保用户具有dba权限,且cmd命令行以管理员身份运行,授予用户dba权限命令:grant connect,resource,dba to 用户名;)


alter user acharts(为用户名称) default tablespace ACHARTS;
 1 将D:/daochu.dmp 中的数据导入 TEST数据库中。
imp jeesite/jeesite@orcl full=y file=d:daochu.dmp

或者


imp jeesite/jeesite@Orcl file=D:daochu.dmp full=y   ignore=y

imp 用户名/密码@数据库名 file=dmp路径 full="y"


imp acharts/acharts@127.0.0.1:1521/orcl file="‪C:UserswdDesktopacharts.dmp" full="y"

用户名和密码应与你导出的远程数据库时的用户名和密码相同


 

删除user
drop user 用户名 cascade
SQL code
--删除空的表空间,但是不包含物理文件
drop tablespace tablespace_name;
--删除非空表空间,但是不包含物理文件
drop tablespace tablespace_name including contents;
--删除空表空间,包含物理文件
drop tablespace tablespace_name including datafiles;
--删除非空表空间,包含物理文件
drop tablespace tablespace_name including contents and datafiles;
--如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段,就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;

PLSQL导入导出表的正确步骤

原来总是直接 tools->import talbes->Oracle Import结果发现有的时候会出错:有的表不能正确导入, baidu+googel解决办法如下:

导出步骤:

1 tools ->export user object 选择选项,导出.sql文件

2 tools ->export tables-> Oracle Export 选择选项导出.dmp文件

导入步骤:

1 tools->import tables->SQL Inserts 导入.sql文件

2 tools->import talbes->Oracle Import然后再导入dmp文件

点击1之后import是灰色按钮,需要点击2刷新,就可以import

数据库的导入导出成功

=======================解释=====================================================================

Tools->Export User Objects导出的是建表语句(包括存储结构)

Tools->Export Tables里面包含三种导出方式:

三种方式都能导出表结构以及数据,网上说三种方法有区别,如下:

Oracle Export,Sql Insert,pl/sql developer 
第一种是导出为.dmp的文件格式,.dmp文件是二进制的,可以跨平台,还能包含权限,效率也很不错,用得最广 
第二种是导出为.sql文件的,可用文本编辑器查看,通用性比较好,但效率不如第一种,适合小数据量导入导出。尤其注意的是表中不能有大字段(blob,clob,long),如果有,会提示不能导出(提示如下: 
table contains one or more LONG columns cannot export in sql format,user Pl/sql developer format instead),可以用第一种和第三种方式导出。 第三种是导出为.pde格式的,.pde为Pl/sql developer自有的文件格式,只能用Pl/sql developer自己导入导出;不能用编辑器查看。

个人比较中意第二种方法,毕竟是SQL文件嘛,自己还可以看,想改也方便

cmd命令行导入dmp(确保用户具有dba权限,且cmd命令行以管理员身份运行,授予用户dba权限命令:grant connect,resource,dba to 用户名;)

imp 用户名/密码@数据库名 file=dmp路径 full="y"
imp acharts/acharts@127.0.0.1:1521/orcl file="‪C:UserswdDesktopacharts.dmp" full="y"

原文地址:https://www.cnblogs.com/miye/p/6977953.html