Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Add Scott user

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

C:\ Users\ Administrator > echo% ORACLE_HOME%

C:\ app\ Administrator\ virtual\ product\ 12.2.0\ dbhome_2

C:\ Users\ Administrator > sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Saturday December 16 09:11:50 2017

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Connect to:

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 MOUNTED

SQL > alter pluggable database clonepdb_plug open

The plug-in database has changed.

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

The session has changed.

SQL > show user

USER is "SYS"

SQL > show con_name

CON_NAME--

CLONEPDB_PLUG

SQL > @% ORACLE_HOME%\ rdbms\ admin\ utlsamplpdb.sql

Disconnect from 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 Saturday December 16 09:22:07 2017

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Connect to:

Oracle Database 12c Enterprise Edition Release 12.2.0.1.0-64bit Production

SQL > alter session set container=CLONEPDB_PLUG

The session has changed.

SQL > select username from dba_users where username = 'SCOTT'

USERNAME

SCOTT

SQL > conn scott/tiger@CLONEPDB_PLUG is connected.

SQL > select table_name from user_tables

TABLE_NAME

DEPT

EMP

BONUS

SALGRADE

Go one step further

C:\ Users\ Administrator > sqlplus/ as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Saturday December 16 10:13:16 2017

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Connect to:

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

The session has changed.

SQL >-- Grant/Revoke system privileges

SQL > grant create session to ROLE_APPPOSERP

Authorization successful.

SQL > grant delete any table to ROLE_APPPOSERP

Authorization successful.

SQL > grant execute any procedure to ROLE_APPPOSERP

Authorization successful.

SQL > grant insert any table to ROLE_APPPOSERP

Authorization successful.

SQL > grant select any sequence to ROLE_APPPOSERP

Authorization successful.

SQL > grant select any table to ROLE_APPPOSERP

Authorization successful.

SQL > grant update any table to ROLE_APPPOSERP

Authorization successful.

SQL > create user DBLINKUSR

2 identified by DBLINKUSR

3 profile DEFAULT

The user has been created.

SQL > grant role_appposerp to DBLINKUSR

Authorization successful.

SQL > alter session set container=pdbtest

The session has changed.

SQL > create database link

2 CLONEPDB_PLUG connect to DBLINKUSR identified by DBLINKUSR

3 using 'CLONEPDB_PLUG'

The database link has been created.

SQL > set wrap off

SQL > set linesize 200

SQL > select * from dual@CLONEPDB_PLUG

DU

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

Synonyms have been created.

SQL > desc emp

Is the name empty? Types

EMPNO

NOT NULL NUMBER (4)

ENAME VARCHAR2 (10)

JOB

VARCHAR2 (9)

MGR

NUMBER (4)

HIREDATE

DATE

SAL

NUMBER (7 dint 2)

COMM

NUMBER (7 dint 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

Synonyms have been created.

SQL > select * from dba_synonyms where SYNONYM_NAME='SCOTTEMP'

OWNER SYNONYM_NAME TABLE_OWNER TABLE_NAME DB_LINK ORIGIN_CON_ID

SYS SCOTTEMP SCOTTEMP CLONEPDB_PLUG 3

The role of Oracle synonyms in database chain

A database chain is a named object that indicates the path from one database to another, through which communication between different databases can be realized.

Create database link database chain name connect to user name identified by password using 'Oracle connection string'; access object through object name @ database chain name. The role of synonyms in the database chain is to provide location transparency.

SQL > drop synonym scottemp

2

Synonyms have been deleted.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report