1 在資料移轉時,使用者首先有許可權修改資料庫,並且進行資料表空間建立、刪除等權利
例如:
select * from dba_tab_privs where grantee='SCOT'; ---查看SCOTT許可權(sys使用者登入)
顯示結果為:
select * from dba_role_privs where grantee='SCOT'; --查看SCOTT角色
顯示結果為:
(1) 如果使用者被鎖定通過以下語句來解鎖表
alter user scott account unlock; --解鎖表
(2) 授予使用者權限
grant connect to scott; --串連資料庫許可權grant resource to scott; --授予建立表等基本許可權grant dba to scott; --授予DBA許可權
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;
最後重新登陸資料庫,驗證新增的遷移資料庫