数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

ORACLE7 用户之间数据拷贝的方法


发布日期:2018年08月12日
 
ORACLE7 用户之间数据拷贝的方法

大型数据库系统不是一个简单的文件系统不象FOXBASE的DBF文件那样可以简单地拷来拷去就拿ORACLE数据库来说数据是隶属于某个用户的每个用户都有各自的权限如果某用户要用另一个用户的数据可以通过访问权限来实现有时需要将某用户的数据直接搬到自己的用户下用可用下边的方法实现

例子

ORACLE数据库服务器操作系统为UNIX

ORACLE用户ouser密码passwd

ORACLE用户ouser密码passwd

现在要做的工作是将用户ouser 的所有的表(视图及其它全部应用)复制到ouser 中去

具体实现方法

将用户ouser的数据卸出

$ exp ouser/passwd

Export:

Export file:expdatdmp>

E(ntire database)()U(sers)or ()T(ables):()U>

Export grants(yes/no):yes>

Export table data(yes/no):yes>

Compress extents(yes/no):yes>

Abort to export specified users

Abort to export OUSERs tables

Export terminated successfully without warnings

最后将ouser用户的数据生成于默认的expdatdmp 文件中

确认已建立用户ouser并赋有相应的权限(一般用户的权限为connect和resource)

将ouser的数据全部复制到ouser

$ imp ouser/passwd

Import:Release

Import file: > expdatdmp

Enter insert buffer size (minimum is ) >

Export file created by EXPORT:

List contents of import file only(yes/no):no>

Ignore create error due to object existence(yes/no):no>

Import grants(yes/no):yes>

Import table data(yes/no):yes>

Import entire export file(yes/no):no>y

开始复制ouser之数据到ouser出现如下提示

importing OUSERs objects into OUSER

importing table table rows imported

Import terminated successfully without warnings

至此ouser的数据已全部复制到了ouser用户中值得注意的是在Import entire export file(yes/no):no>y选择的是y若选择no就不能完成复制工作

上一篇:oracle--SQL 变量

下一篇:关于触发器修改自身数据表实例