oracle数据库数据的迁移,Oracle数据库迁移方案

1 在数据迁移时,用户首先有权限修改数据库,并且进行表空间创建、删除等权利

例如:

?

显示结果为:

?

显示结果为:

(1) 如果用户被锁定通过以下语句来解锁表

?

(2) 授予用户权限

?

2 建立表空间

严格意义上在先执行如下命令而不是直接开始建立表空间

?

然后开始创建表空间

create tablespace xx_bp;

datafile 'F:\app\xx_bp.ora' --表空间的本地位置

size 50M

autoextend on next 1M;

附:datafile 为表空间对应的数据文件,后面跟随数据文件的路径及数据文件名

size 为数据文件的初始大小

autoextend on 表示数据随着数据量的增加自动扩大

一般在创建表的时候会创建多个表空间用来存放各种数据,比如我们一般会创建历史表空间(HS)、索引表空间等。另外先建立表空间,然后建立用户时指向此表空间,否则oracle会默认将用户指向sys表空间

3 创建用户

create user 用户名 indentified by 密码 tablespace xx_bp,xx_hs,xx_indx;

附: identified by 为创建用户密码的关键字,后面跟随的是用户密码

4 对数据库的用户进行授权

grant connect,resource to 用户名

将connect 和resource 角色授予用户

查看当前用户有哪些角色

select * from user_role_privs;

5 建立数据结构、存储过程、视图、序列

(1)创建表

create table XX.BP_OPER_DETAIL_TB

(

task_id VARCHAR2(50) not null,

flow_id NUMBER(19) not null,

task_no VARCHAR2(50) not null,

flow_node VARCHAR2(4) not null,

workitemid NUMBER(19) not null,

trans_id VARCHAR2(10) not null,

trans_no CHAR(6) not null,

vouch_group VARCHAR2(10) not null,

teller_no VARCHAR2(15) default '',

user_no VARCHAR2(15) not null,

organ_no VARCHAR2(10) not null,

areacode VARCHAR2(5) default '',

create_time CHAR(14) not null,

checkout_time CHAR(14) not null,

checkin_time CHAR(14) default '',

suspend_time CHAR(14) default '',

resume_time CHAR(14) default '',

trans_time INTEGER default 0,

release_time INTEGER default 0,

state INTEGER not null,

result VARCHAR2(10) default '',

reason VARCHAR2(512) default ''

)

tablespace XX_BP pctfree 10 initrans 1 maxtrans 255 storage

(

initial 64K next 8K minextents 1 maxextents unlimited

);

创建索引约束调节等

alter table XX.BP_OPER_DETAIL_TB add constraint BP_OPER_DETAIL_PK primary key

(

TASK_ID, WORKITEMID, FLOW_NODE

)

using index tablespace XX_BP pctfree 10 initrans 2 maxtrans 255 storage

(

initial 64K next 1M minextents 1 maxextents unlimited

);

6 导入数据

insert into SM_FIELD_PARENT_TB (field_id, parent_field, last_modi_date)

values ('VH0007', 'VH0000', '20160420074707');

insert into SM_FIELD_PARENT_TB (field_id, parent_field, last_modi_date)

values ('VH0008', 'VH0000', '20160420074729');

insert into SM_FIELD_PARENT_TB (field_id, parent_field, last_modi_date)

values ('VH0010', 'VH0000', '20160420074818');

insert into SM_FIELD_PARENT_TB (field_id, parent_field, last_modi_date)

values ('VH0012', 'VH0000', '20160420074914');

insert into SM_FIELD_PARENT_TB (field_id, parent_field, last_modi_date)

values ('VH0016', 'VH0000', '20160420075055');

insert into SM_FIELD_PARENT_TB (field_id, parent_field, last_modi_date)

values ('VH0017', 'VH0000', '20160420075129');

insert into SM_FIELD_PARENT_TB (field_id, parent_field, last_modi_date)

values ('VH0021', 'VH0000', '20160420075305');

commit;

最后重新登陆数据库,验证新增的迁移数据库

原文链接:http://www.cnblogs.com/beyondyourself/archive/2016/11/27/6106208.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值