C:\Users\Administrator>echo %ORACLE_HOME%
C:\app\Administrator\virtual\product\12.2.0\dbhome_2
C:\Users\Administrator>sqlplus / as sysdbasql
SQL*Plus: Release 12.2.0.1.0 Production on 星期六 12月 16 09:11:50 2017數據庫
Copyright (c) 1982, 2016, Oracle. All rights reserved.session
鏈接到:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Productionapp
SQL> show pdbside
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO 3 PDBTEST READ WRITE NO 4 CLONEPDB_PLUG MOUNTED
SQL> alter pluggable database clonepdb_plug open;code
插接式數據庫已變動。對象
SQL> show pdbsblog
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO 3 PDBTEST READ WRITE NO 4 CLONEPDB_PLUG READ WRITE NO
SQL> alter session set container=CLONEPDB_PLUG;it
會話已更改。
SQL> show user
USER 爲 "SYS"
SQL> show con_name;
CON_NAME ------------------------------
CLONEPDB_PLUG
SQL> @%ORACLE_HOME%\rdbms\admin\utlsamplpdb.sql
從 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 斷開
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on 星期六 12月 16 09:22:07 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved. io
鏈接到:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> alter session set container=CLONEPDB_PLUG;
會話已更改。
SQL> select username from dba_users where username = 'SCOTT';
SCOTT
SQL> conn scott/tiger@CLONEPDB_PLUG 已鏈接。
SQL> select table_name from user_tables;
DEPT
EMP
BONUS
SALGRADE
深刻一步
C:\Users\Administrator>sqlplus/ as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on 星期六 12月 16 10:13:16 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
鏈接到:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO 3 PDBTEST READ WRITE NO 4 CLONEPDB_PLUG READ WRITE NO
SQL> alter session set container=CLONEPDB_PLUG;
會話已更改。
SQL> -- Grant/Revoke system privileges
SQL> grant create session to ROLE_APPPOSERP;
受權成功。
SQL> grant delete any table to ROLE_APPPOSERP;
受權成功。
SQL> grant execute any procedure to ROLE_APPPOSERP;
受權成功。
SQL> grant insert any table to ROLE_APPPOSERP;
受權成功。
SQL> grant select any sequence to ROLE_APPPOSERP;
受權成功。
SQL> grant select any table to ROLE_APPPOSERP;
受權成功。
SQL> grant update any table to ROLE_APPPOSERP;
受權成功。
SQL> create user DBLINKUSR
2 identified by DBLINKUSR
3 profile DEFAULT;
用戶已建立。
SQL> grant role_appposerp to DBLINKUSR;
受權成功。
SQL> alter session set container=pdbtest;
X
SQL> select * from dba_db_links;
OWNER DB_LINK USERNAME HOST CREATED HIDDEN
SYS SYS_HUB SEEDDATA 2017/3/8 16 NO
SYS CLONEPDB_PLUG DBLINKUSR CLONEPDB_PLUG 2017/12/16 NO
PUBLIC DBMS_CLRDBLINK ORACLR_CONNECTION_DATA 2017/12/13 NO
SQL> select * from link$;
OWNER# NAME CTIME HOST USERID PASSWORD FLAG AUTHUSR AUTHPWD PASSWORDX AUTHPWDX
0 SYS_HUB 2017/3/8 16 SEEDDATA 0 0 CLONEPDB_PLUG 2017/12/16 CLONEPDB_PLUG DBLINKUSR 2 0706B6180908B91436DD15579A9716C7AA59A171BE0F860141B44815E4A93536B3ECE15A339EB407 1 DBMS_CLRDBLINK 2017/12/13 ORACLR_CONNECTION_DATA 0
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ----------
3 PDBTEST READ WRITE NO SQL> create public synonym emp for scott.emp@CLONEPDB_PLUG;
同義詞已建立。
SQL> desc emp
名稱 是否爲空? 類型
EMPNO
NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB
VARCHAR2(9)
MGR
NUMBER(4)
HIREDATE
DATE
SAL
NUMBER(7,2)
COMM
NUMBER(7,2)
DEPTNO
NUMBER(2)
SQL> select * from dba_synonyms where SYNONYM_NAME='EMP';
OWNER SYNONYM_NAME TABLE_OWNER TABLE_NAME DB_LINK ORIGIN_CON_ID
PUBLIC EMP SCOTT EMP CLONEPDB_PLUG 3
SQL> create synonym scottemp for scott.emp@CLONEPDB_PLUG;
同義詞已建立。
SQL> select * from dba_synonyms where SYNONYM_NAME='SCOTTEMP';
OWNER SYNONYM_NAME TABLE_OWNER TABLE_NAME DB_LINK ORIGIN_CON_ID
SYS SCOTTEMP SCOTT EMP CLONEPDB_PLUG 3Oracle同義詞在數據庫鏈中的做用 數據庫鏈是一個命名的對象,說明一個數據庫到另外一個數據庫的路徑,經過其能夠實現不一樣數據庫之間的通訊。 Create database link 數據庫鏈名 connect to user名 identified by 口令 using ‘Oracle鏈接串’; 訪問對象要經過 object名@數據庫鏈名。同義詞在數據庫鏈中的做用就是提供位置透明性。SQL> drop synonym scottemp2 ; 同義詞已刪除。