导出,在DOS下执行:
1.exp username/userpassword@databaseName //可以是数据库也可是远程的,如username/userpassword@caac135
2.Enter array fetch buffer size: 4096 > 回车
3.Export file: expdat.dmp > e:/temp/m.dmp (生成导出的文件名 )
4.(1)E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 3
5.Export table data (yes/no): yes > 回车
6.Compress extents (yes/no): yes > 回车
7.Export done in ZHS16GBK character set and ZHS16GBK NCHAR character set
About to export specified tables via Conventional Path ...
Table(T) or Partition(T:P) to be exported: (RETURN to quit) > tablename 要导出的表名
. . exporting table CMAMENU 4336 rows exported
Table(T) or Partition(T:P) to be exported: (RETURN to quit) > 要导出的表名n
Table(T) or Partition(T:P) to be exported: (RETURN to quit) > 回车
Export terminated successfully without warnings.
这是导出某个表.如果要导出某用户下所有对象,步骤4选2.
4.(1)E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 2
参考其他:
导入导出的实例,向导入导出看实例基本上就可以完成,因为导入导出很简单。
数据导出:
1 将数据库TEST完全导出,用户名system 密码manager 导出到D:/daochu.dmp中
exp system/manager@TEST file=d:/daochu.dmp full=y
2 将数据库中system用户与sys用户的表导出
exp system/manager@TEST file=d:/daochu.dmp owner=(system,sys)
3 将数据库中的表table1 、table2导出
exp system/manager@TEST file=d:/daochu.dmp tables=(table1,table2)
3.1 将数据库中的表t,s开头的表导出
exp system/manager@TEST file=d:/daochu.dmp tables=(t%,s%)
4 将数据库中的表table1中的字段filed1以"00"打头的数据导出
exp system/manager@TEST file=d:/daochu.dmp tables=(table1) query=/" where filed1 like '00%'/"
导入:
1、通过system登录数据库管理平台,如果不记得密码,在CMD中用以下命令修改.
(sqlplus /nolog
connect / as sysdba
alter user system identified by li)
2、建立数据库空间,名称为caa,大小为1024M
3、建立用户,名称为li,密码为li,建立用户时选择表空间为caac,临时表空间为temp
系统角色选择connect,resourse,系统权限选择create table_space,unlimited table_space.用命令类似如下:
(SQL> create tablespace TS_ENCAR
前四步是针对数据库刚建立或已经将部分数据删除.大部分情况只要执行第5步即可.
导入单表
ignore=y 表示忽略创建错误,继续后面的操作
1.如果原数据库表存在,只需添加新加入数据可用以下命令.
imp li/li@caa file =E:/m.dmp full=y ignore=y indexes=n
(Oracle在恢复数据的过程中,当恢复某个表时,该表已经存在,就要根据ignore参数的设置来决定如何操作。
若ignore=y,Oracle不执行CREATE TABLE语句,直接将数据插入到表中,如果插入的记录违背了约束条件,比如主键约束,则出错的记录不会插入,但合法的记录会添加到表中。
若ignore=n,Oracle不执行CREATE TABLE语句,同时也不会将数据插入到表中,而是忽略该表的错误,继续恢复下一个表。
2. indexes参数
在恢复数据的过程中,若indexes=n,则表上的索引不会被恢复,但是主键对应的唯一索引将无条件恢复,这是为了保证数据的完整性。)
2.如果要将原数据库表中数据全部清除.则需要将原表先删除后加.简单的做法就是可以先删除该用户,再导入数据.
删除用户语名: drop user 用户名 cascade;
不用权限用户可能会出权限不足的问题,绐被导入的用户赋予导入相同的权限,将数据导入后再撤消权限即可。
撤消用户权限语句: revoke dba from username4;将username4用户DBA用户取消