Oracle 12c CDB&PDBs管理
本文摘取Database Administrator’s Guide(12.1.0.2)中40,42等章節部分內容,概括介紹管理CDB、PDBs任務。摘取翻譯的內容側重操作和例項,詳細內容請參考官方文件:
40 Administering a CDB with SQL*Plus
42 Administering PDBs with SQL*Plus
1. CDB 管理任務
Table 40-1 Administrative Tasks Common to CDBs and Non-CDBs
Task |
Description |
Starting up a CDB instance |
To start a CDB instance, the current user must be a common user whose current container is the root.
When you open a CDB, its PDBs are mounted. Use the
|
Managing processes |
A CDB has one set of background processes shared by the root and all PDBs. |
Managing memory |
A CDB has a single system global area (SGA) and a single aggregate program glob al area (PGA). The memory required by a CDB is the sum of the memory requirements for all of the PDBs that will be part of the CDB. |
Managing security |
You can create and drop common users and local users in a CDB. You can also grant privileges to and revoke privileges from these users. You can also manage the
In addition, grant the following roles to the appropriate users:
·
Grant the
·
Grant the
|
Monitoring errors and alerts |
A CDB has one alert log for the entire CDB. The name of a PDB is included in records in trace files, when appropriate. |
Managing diagnostic data |
In a CDB, you can use the Oracle Database fault diagnosability infrastructure and the Automatic Diagnostic Repository (ADR). |
Managing control files |
A CDB has one control file. |
Managing the online redo log and the archived redo log files |
A CDB has one online redo log and one set of archived redo log files. |
Managing tablespaces |
You can create, modify, and drop tablespaces and temporary tablespaces for the root and for individual PDBs. You can also specify a default tablespace, default tablespace type, and a default temporary tablespace for the root. The root has its own set of Oracle-supplied tablespaces, such as the
|
Managing data files and temp files |
The root has its own data files, and each PDB has its own data files. In a CDB, you can manage data files and temp files in basically the same way you would manage them for a non-CDB. However, the following exceptions apply to CDBs:
·
You can limit the amount of storage used by the data files for a PDB by using the
· There is a default temporary tablespace for the root and for each PDB. |
Managing undo |
There is one active undo tablespace for a single-instance CDB. For an Oracle RAC CDB, there is one active undo tablespace for each instance. In a CDB, the
Only a common user who has the appropriate privileges and whose current container is the root can create an undo tablespace. Undo tablespaces are visible in static data dictionary views and dynamic performance (V$) views when the current container is the root. Undo tablespaces are visible only in dynamic performance views when the current container is a PDB. When the current container is a PDB, an attempt to create an undo tablespace fails without returning an error. |
Moving data between PDBs |
You can move data between PDBs using the same methods that you would use to move data between non-CDBs. For example, you can transport the data or use Data Pump export/import to move the data. |
Using Oracle Managed Files |
Using Oracle Managed files can simplify administration for both a CDB and a non-CDB. |
Using Transparent Data Encryption |
Transparent Data Encryption is a feature that enables encryption of individual table columns before storing them in the data file, or enables encryption of entire tablespaces. In a CDB, each PDB has its own master key for Transparent Data Encryption, and, where applicable, the
|
Using a standby database |
Oracle Data Guard can configure a physical standby or a logical standby of a CDB. Data Guard operates on the entire CDB, not on individual PDBs. |
Using Oracle Database Vault |
Oracle Database Vault policies are scoped to individual PDBs. |
Dropping a database |
When you drop a CDB, the root, seed, and all of its PDBs (including their data) are also dropped.
You can also drop individual PDBs with the
|
2. CDB 中的可管理特性
Table 40-2 Manageability Features in a CDB
Manageability Feature |
Data Location |
Data Visibility |
Active Session History (ASH) ASH collects information about active database sessions. You can use this information to analyze and identify performance issues. |
Most of the ASH data is stored in memory. A small percentage of the ASH data samples are stored in the root. ASH data related to a PDB is not included if the PDB is unplugged. |
A common user whose current container is the root can view ASH data for the root and for PDBs. A user whose current container is a PDB can view ASH data for the PDB only. |
Alerts An alert is a notification of a possible problem. |
Threshold settings that pertain to a PDB are stored in the PDB. Alerts posted when thresholds are violated are enqueued into the alert queue in the root. Threshold settings that pertain to a PDB are included if the PDB is unplugged. Alerts related to a PDB are not included if the PDB is unplugged. |
A common user whose current container is the root can view alerts for the root and for PDBs. A user whose current container is a PDB can view alert thresholds and alerts for the PDB only. |
Automated Database Maintenance Tasks Automated database maintenance tasks are tasks that are started automatically at regular intervals to perform maintenance operations on the database. Automated tasks include automatic optimizer statistics collection, Automatic Segment Advisor tasks, and Automatic SQL Tuning Advisor tasks. |
A user can schedule maintenance windows and enable or disable maintenance tasks for the current container only. If the current container is the root, then the changes only apply to the root. If the current container is a PDB, then the changes only apply to the PDB. Data related to a PDB is stored in the PDB for automatic optimizer statistics collection and the Automatic Segment Advisor. This data is included if the PDB is unplugged. Automatic SQL Tuning Advisor runs only in the root. See the SQL Tuning Advisor row in this table for information about data collected by Automatic SQL Tuning Advisor. |
See the appropriate row in this table for data visibility information about the following manageability features: automatic optimizer statistics collection, Automatic Segment Advisor, and Automatic SQL Tuning Advisor. |
Automatic Database Diagnostic Monitor (ADDM) ADDM can diagnose a database's performance and determine how identified problems can be resolved. |
All ADDM runs must be performed in the root. All ADDM results are stored in the root. ADDM analyzes activity in a PDB within the context of the current analysis target. ADDM does not analyze one PDB at a time. As in previous releases, ADDM runs with a target of either the entire instance or Oracle RAC database. ADDM results related to a PDB are not included if the PDB is unplugged. |
ADDM results are visible only to a common user whose current container is the root. The ADDM results can include information about multiple PDBs. The ADDM results cannot be viewed when the current container is a PDB. |
Automatic Optimizer Statistics Collection Automatic optimizer statistics collection gathers optimizer statistics for all schema objects in the database for which there are no statistics or only stale statistics. The statistics gathered by this task are used by the SQL query optimizer to improve the performance of SQL execution. |
When an automatic optimizer statistics collection task gathers data for a PDB, it stores this data in the PDB. This data is included if the PDB is unplugged. |
A common user whose current container is the root can view optimizer statistics data for PDBs. A user whose current container is a PDB can view optimizer statistics data for the PDB only. |
Automatic Segment Advisor The Automatic Segment Advisor identifies segments that have space available for reclamation and makes recommendations on how to defragment those segments. |
When Automatic Segment Advisor gathers data for a PDB, it stores this data in the PDB. This data is included if the PDB is unplugged. |
A common user whose current container is the root can view Automatic Segment Advisor data for PDBs. A user whose current container is a PDB can view the Automatic Segment Advisor data for the PDB only. |
Automatic Workload Repository (AWR) The AWR collects, processes, and maintains performance statistics for problem detection and self-tuning purposes. This data is stored in the database. The gathered data can be displayed in both reports and views. |
AWR data is stored in the root. AWR data related to a PDB is not included if the PDB is unplugged. |
A common user whose current container is the root can view AWR data for the root and for PDBs. A user whose current container is a PDB can view AWR data for the PDB only. |
Database Replay Database Replay is a feature of Oracle Real Application Testing. Database Replay captures the workload for a database and replays it exactly on a test database. |
Information about database captures and replays are stored in the root. |
A common user whose current container is the root can view database capture and replay information. |
SQL Management Base (SMB) SMB stores statement logs, plan histories, SQL plan baselines, and SQL profiles in the data dictionary. |
SMB data related to a PDB is stored in the PDB. The SMB data related to a PDB is included if the PDB is unplugged. |
A common user whose current container is the root can view SMB data for PDBs. A user whose current container is a PDB can view the SMB data for the PDB only. |
SQL Performance Analyzer (SPA) SPA can analyze the SQL performance impact of SQL tuning and other system changes. SPA is often used with Database Replay. |
A common user whose current container is the root can run SPA for any PDB. In this case, the SPA results data is stored in the root and is not included if the PDB is unplugged. A user whose current container is a PDB can run SPA on the PDB. In this case, the SPA results data is stored in the PDB and is included if the PDB is unplugged. |
A common user whose current container is the root can view SPA results data for PDBs. A user whose current container is a PDB can view the SPA results data for the PDB only. |
SQL Tuning Sets (STS) An STS is a database object that includes one or more SQL statements along with their execution statistics and execution context, and could include a user priority ranking. You can use an STS to tune a group of SQL statements or test their performance using SPA. |
An STS can be stored in the root or in any PDB. If it is stored in the root, then you can load SQL statements from any PDB into it. When a PDB is unplugged, an STS stored in the root is not included, even if the STS contains SQL statements from the PDB. When a PDB is unplugged, an STS stored in the PDB is included. |
A common user whose current container is the root can view STS data stored in the root only. A user whose current container is a PDB can view STS data for the PDB only. |
SQL Tuning Advisor SQL Tuning Advisor optimizes SQL statements that have been identified as high-load SQL statements. |
Automatic SQL Tuning Advisor data is stored in the root. It might have results about SQL statements executed in a PDB that were analyzed by the advisor, but these results are not included if the PDB is unplugged. A common user whose current container is the root can run SQL Tuning Advisor manually for SQL statements from any PDB. When a statement is tuned, it is tuned in any container that runs the statement. A user whose current container is a PDB can also run SQL Tuning Advisor manually for SQL statements from the PDB. When SQL Tuning Advisor is run manually from a PDB, the results are stored in the PDB from which it is run. In this case, a statement is tuned only for the current PDB, and the results related to a PDB are included if the PDB is unplugged. |
When SQL Tuning Advisor is run automatically, the results are visible only to a common user whose current container is the root. These results cannot be viewed when the current container is a PDB. When SQL Tuning Advisor is run manually by a user whose current container is a PDB, the results are only visible to a user whose current container is that PDB. |
3. 管理資料庫物件
在 CDB 中,不同的容器可以包含不同的資料庫物件。
Oracle 資料庫儲存資料庫物件,如表、索引和目錄。屬於模式的資料庫物件稱為模式物件,而不屬於模式的資料庫物件稱為非模式物件。 root 和 PDBs 包含模式,模式包含模式物件。 root 和 PDBs 還可以包含非模式物件,比如使用者、角色、表空間、目錄和版本。
在 CDB 中, root 包含 oracle 提供的模式和資料庫物件。 oracle 提供的 Common User ,如 SYS 和 SYSTEM ,擁有這些模式和公共資料庫物件。它們還可以擁有 root 和 PDB 中的本地物件。
您可以在 root 中建立 Common User 來管理 CDB 中的容器。使用者建立的 Common User 可以在 root 中建立資料庫物件。 Oracle 建議,在 root 中,由使用者建立的 Common User 擁有的模式只包含資料庫觸發器及其定義中使用的物件。使用者建立的 Common User 還可以擁有 PDB 中的任何型別的本地物件。
您可以在 PDB 中建立 Local User 。 PDB 中的 Local User 可以在 PDB 中建立模式物件和非模式物件。不能在 root 中建立 Local User 。
CDB 中的名稱解析類似於非 CDB 中的名稱解析,只不過名稱是在使用者當前容器的字典上下文中解析的。
4. SQL*PLUS 訪問容器的方法
#本地連線到root
sqlplus /nolog
connect system
connect / as sysdba
#透過服務名連線到root
connect c##dba@mycdb
#連線到pdbs
CONNECT sh@salespdb
CONNECT system@salespdb
#切換容器
ALTER SESSION SET CONTAINER = container_name
ALTER SESSION SET CONTAINER = CDB$ROOT;
ALTER SESSION SET CONTAINER = PDB$SEED;
ALTER SESSION SET CONTAINER = salespdb;
5. 跨容器執行 CODE: DBMS_SQL
DECLARE
c1 INTEGER;
rowcount INTEGER;
taskList VARCHAR2(32767) :=
'DECLARE
PRAGMA AUTONOMOUS TRANSACTION;
BEGIN
-- Create the hr.identact table.
EXECUTE IMMEDIATE
''CREATE TABLE hr.identact
(actionno NUMBER(4) NOT NULL,
action VARCHAR2 (10))'';
EXECUTE IMMEDIATE
''INSERT INTO identact VALUES(1, 'ACTION1')'';
-- A commit is required if the tasks include DML.
COMMIT;
EXCEPTION
WHEN OTHERS THEN
-- If there are errors, then drop the table.
BEGIN
EXECUTE IMMEDIATE ''DROP TABLE identact'';
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END;';
TYPE containerListType IS TABLE OF VARCHAR2(128) INDEX BY PLS_INTEGER;
containerList containerListType;
BEGIN
containerList(1) := 'PDB1';
containerList(2) := 'PDB2';
c1 := DBMS_SQL.OPEN_CURSOR;
FOR conIndex IN containerList.first..containerList.last LOOP
DBMS_OUTPUT.PUT_LINE('Creating in container: ' || containerList(conIndex));
DBMS_SQL.PARSE(c => c1 ,
statement => taskList,
language_flag => DBMS_SQL.NATIVE,
edition= > NULL,
apply_crossedition_trigger => NULL,
fire_apply_trigger => NULL,
schema => 'HR',
container => containerList(conIndex));
rowcount := DBMS_SQL.EXECUTE(c=>c1);
END LOOP;
DBMS_SQL.CLOSE_CURSOR(c=>c1);
END;
/
6. CDB&PDBs 管理操作
Ø CDB 管理任務
管理 CDB 的操作透過 alter database ,對於不同 container 有不同的 clause ,大體可以分三部分,一是對整個 CDB 的修改操作,二是僅對 root 的修改操作,三是對 1 個或多個 PDB 的操作;詳解見下表:
Table 40-3 Statements That Modify Containers in a CDB
Modify Entire CDB |
Modify Root Only |
Modify One or More PDBs |
When connected as a common user whose current container is the root,
· · · · · ·
·
·
·
|
When connected as a common user whose current container is the root,
·
·
·
·
·
·
· You can use these clauses to set non-default values for specific PDBs. |
When connected as a common user whose current container is the root,
·
When the current container is a PDB,
When connected as a common user whose current container is the root,
· |
1) 對整個 CDB 的修改操作
例如:
ALTER DATABASE BACKUP CONTROLFILE TO '+DATA/dbs/backup/control.bkp';
ALTER DATABASE cdb ADD LOGFILE
GROUP 4 ('/u01/logs/orcl/redo04a.log','/u02/logs/orcl/redo04b.log')
SIZE 100M BLOCKSIZE 512 REUSE;
2) 僅對 root 的修改操作
Example 40-11 Changing the Default Permanent Tablespace for the Root
ALTER DATABASE DEFAULT TABLESPACE root_tbs;
Example 40-12 Bringing a Data File Online for the Root
ALTER DATABASE DATAFILE '/u02/oracle/cdb_01.dbf' ONLINE;
Example 40-13 Changing the Default Tablespace Type for the Root
ALTER DATABASE SET DEFAULT BIGFILE TABLESPACE;
Example 40-14 Changing the Default Temporary Tablespace for the Root
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE root_temp;
3) 對 1 個或多個 PDB 的操作
Example 40-15 Changing the Open Mode of Listed PDBs
ALTER PLUGGABLE DATABASE salespdb, hrpdb OPEN READ WRITE;
ALTER PLUGGABLE DATABASE salespdb
OPEN READ ONLY RESTRICTED;
ALTER PLUGGABLE DATABASE salespdb
OPEN UPGRADE;
ALTER PLUGGABLE DATABASE ALL
OPEN READ WRITE;
ALTER PLUGGABLE DATABASE ALL
OPEN READ WRITE FORCE;
ALTER PLUGGABLE DATABASE ALL EXCEPT salespdb, hrpdb
CLOSE IMMEDIATE;
Example 40-18 Opening a PDB in Read/Write Mode with the STARTUP Command
STARTUP PLUGGABLE DATABASE hrpdb OPEN
STARTUP PLUGGABLE DATABASE hrpdb RESTRICT
STARTUP PLUGGABLE DATABASE hrpdb OPEN READ ONLY RESTRICT
STARTUP PLUGGABLE DATABASE hrpdb OPEN READ ONLY
STARTUP PLUGGABLE DATABASE hrpdb FORCE
4) restart CDB 時,保留或丟棄 PDB 的 open mode 狀態
PDB 在 CDB 啟動時預設為 mount 狀態,你可以這樣做 :
l
當
CDB
重啟時,指定
SAVE STATE
以儲存
PDBs
模式。
例如,如果 PDB 在重啟前處於開讀 / 寫模式,那麼在重啟後 PDB 處於開讀 / 寫模式 ; 如果在重啟 CDB 之前 PDB 處於 mount 模式,那麼在重啟 CDB 之後 PDB 也處於 mount 模式。
l
指定
DISCARD STATE
,以便在
CDB
重啟時忽略
PDBs
的
open
模式。
當為
PDB
指定
DISCARD STATE
時,總是在重新啟動
CDB
之後掛載
PDB
。
對於 Oracle RAC CDB 中的 PDB , save state 和 discard state 隻影響當前例項的模式。即使在 instances 子句中指定了多個例項,它們也不會影響其他例項的模式。
在 Oracle RAC CDB 中的 PDB ,如果建立 service 時,指定了 -pdb 選項,啟動 service 時,同時也會 open 對應的 pdb ;
如何查詢 saved state 的 pdbs ?
col con_name for a20
col instance_name for a20
set linesize 200
select * from DBA_PDB_SAVED_STATES ;
您可以透過以下方式指定要修改哪些 PDBs:
l 列出一個或多個 PDBs 。
l 指定 ALL 來修改所有的 PDBs 。
l 指定例外 PDBs 外的所有 PDBs ,列出的 PDBs 除外。
Example 40-23 Preserving the Open Mode of a PDB When the CDB Restarts
ALTER PLUGGABLE DATABASE salespdb SAVE STATE;
Example 40-24 Discarding the Open Mode of a PDB When the CDB Restarts
ALTER PLUGGABLE DATABASE salespdb DISCARD STATE;
Example 40-25 Preserving the Open Mode of All PDBs When the CDB Restarts
ALTER PLUGGABLE DATABASE ALL SAVE STATE;
Example 40-26 Preserving the Open Mode of Listed PDBs When the CDB Restarts
ALTER PLUGGABLE DATABASE salespdb, hrpdb SAVE STATE;
Example 40-27 Preserving the Open Mode of All PDBs Except for Listed Ones When the CDB Restarts
ALTER PLUGGABLE DATABASE ALL EXCEPT salespdb, hrpdb SAVE STATE;
5) CDB 中 ALTER SYSTEM SET 語句
ALTER SYSTEM RESET OPEN_CURSORS SCOPE = SPFILE;
Example 40-28 Setting an Initialization Parameter for All Containers
ALTER SYSTEM SET OPEN_CURSORS = 200 CONTAINER = ALL;
Example 40-29 Setting an Initialization Parameter for the Root
ALTER SYSTEM SET OPEN_CURSORS = 200 CONTAINER = CURRENT;
6) CDB 中 DDL 語句
Table 40-8 DDL Statements and the CONTAINER Clause in a CDB
DDL Statement |
CONTAINER = CURRENT |
CONTAINER = ALL |
|
Creates a local user in the current PDB. |
Creates a common user. |
|
Alters a local user in the current PDB. |
Alters a common user. |
|
Creates a local role in the current PDB. |
Creates a common role. |
|
Grants a privilege in the local container to a local user, common user, or local role.
The
|
Grants a system privilege or object privilege on a common object to a common user or common role. The specified privilege is granted to the user or role across the entire CDB. |
|
Revokes a privilege in the local container from a local user, common user, or local role.
This statement can revoke only a privilege granted with
The
|
Revokes a system privilege or object privilege on a common object from a common user or common role. The specified privilege is revoked from the user or role across the entire CDB.
This statement can revoke only a privilege granted with
|
Example 40-30 Creating Local User in a PDB
CREATE USER testpdb IDENTIFIED BY password
DEFAULT TABLESPACE pdb1_tbs
QUOTA UNLIMITED ON pdb1_tbs
CONTAINER = CURRENT;
Example 40-31 Creating Common User in a CDB
CREATE USER c##testcdb IDENTIFIED BY password
DEFAULT TABLESPACE cdb_tbs
QUOTA UNLIMITED ON cdb_tbs
CONTAINER = ALL;
7) CDB 中執行 SQL 指令碼
Example 40-32 Running the catblock.sql Script in All Containers in a CDB
$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS
-d $ORACLE_HOME/rdbms/admin -b catblock_output catblock.sql
Example 40-33 Running the catblock.sql Script in Specific PDBs
$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS -U SYS
-d $ORACLE_HOME/rdbms/admin -l '/disk1/script_output' -c 'HRPDB SALESPDB'
-b catblock_output catblock.sql
Example 40-34 Running the catblock.sql Script in All Containers Except for Specific PDBs
$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS
-d $ORACLE_HOME/rdbms/admin -l '/disk1/script_output' -C 'HRPDB SALESPDB'
-b catblock_output catblock.sql
Example 40-35 Running a SQL Script with Command Line Parameters
$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS
-d /u01/scripts -b custom_script_output custom_script.sql
'--phr' '--PEnter password for user hr:'
Example 40-36 Running a SQL Statement in All Containers in a CDB
$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS -e -b select_output -- --x"SELECT * FROM DUAL"
8) shutdown CDB
SQL*Plus |
SRVCTL (When Oracle Restart Is In Use) |
SHUTDOWN IMMEDIATE |
srvctl stop database -db db_unique_name -stopoption immediate |
SHUTDOWN TRANSACTIONAL |
srvctl stop database -db db_unique_name -stopoption transactional |
SHUTDOWN ABORT |
srvctl stop database -db db_unique_name -stopoption abort |
Ø PDB 管理任務
Table 42-1 Administrative Tasks Common to PDBs and Non-CDBs
Task |
Description |
Managing tablespaces |
You can create, modify, and drop tablespaces for a PDB. You can specify a default tablespace and default tablespace type for each PDB. Also, there is a default temporary tablespace for each PDB. You optionally can create additional temporary tablespaces for use by individual PDBs. |
Managing data files and temp files |
Each PDB has its own data files. You can manage data files and temp files in the same way that you would manage them for a non-CDB. You can also limit the amount of storage used by the data files for a PDB by using the
|
Managing schema objects |
You can create, modify, and drop schema objects in a PDB in the same way that you would in a non-CDB. You can also create triggers that fire for a specific PDB.
When you manage database links in a CDB, the root has a unique global database name, and so does each PDB. The global name of the root is defined by the
|
9) PDB 中的 ALTER PLUGGABLE DATABASE
Example 42-2 Changing the Open Mode of a PDB
ALTER PLUGGABLE DATABASE CLOSE IMMEDIATE;
ALTER PLUGGABLE DATABASE OPEN READ ONLY;
ALTER PLUGGABLE DATABASE OPEN FORCE;
ALTER PLUGGABLE DATABASE OPEN UPGRADE;
Example 42-3 Bringing a Data File Online for a PDB
ALTER PLUGGABLE DATABASE DATAFILE '/u03/oracle/pdb1_01.dbf' ONLINE;
Example 42-4 Changing the Default Tablespaces for a PDB
ALTER PLUGGABLE DATABASE DEFAULT TABLESPACE pdb1_tbs;
ALTER PLUGGABLE DATABASE DEFAULT TEMPORARY TABLESPACE pdb1_temp;
Example 42-5 Changing the Default Tablespace Type for a PDB
ALTER PLUGGABLE DATABASE SET DEFAULT BIGFILE TABLESPACE;
Example 42-6 Setting Storage Limits for a PDB
ALTER PLUGGABLE DATABASE STORAGE(MAXSIZE 2G);
ALTER PLUGGABLE DATABASE STORAGE(MAXSIZE UNLIMITED);
ALTER PLUGGABLE DATABASE STORAGE UNLIMITED;
Example 42-7 Setting the Logging Attribute of a PDB
ALTER PLUGGABLE DATABASE NOLOGGING;
Example 42-8 Setting the Force Logging Mode of a PDB
ALTER PLUGGABLE DATABASE ENABLE FORCE LOGGING;
Example 42-9 Setting the Default Edition for a PDB
ALTER PLUGGABLE DATABASE DEFAULT EDITION = PDB1E3;
10) PDB 的 STARTUP 、 SHUTDOWN 命令
執行 STARTUP 、 SHUTDOWN 必須符合以下條件:
• 當前使用者必須擁有 SYSDBA 、 SYSOPER 、 SYSBACKUP 或 SYSDG 管理許可權,許可權必須在 PDB 中被公共授予或本地授予。使用者必須在連線時分別使用 SYSDBA 、 SYSOPER 、 SYSBACKUP 或 SYSDG 來行使許可權。
• 除使用 FORCE 選項外, PDB 必須處於掛載模式才能開啟。
• 要將 PDB 置於掛載模式, PDB 必須處於 open 只讀或 open read/write 模式。
Example 42-10 Opening a PDB in Read/Write Mode with the STARTUP Command
STARTUP OPEN
Example 42-11 Opening a PDB in Read-Only Mode with the STARTUP Command
STARTUP OPEN READ ONLY
Example 42-12 Opening a PDB in Read-Only Restricted Mode with the STARTUP Command
STARTUP RESTRICT OPEN READ ONLY
Example 42-13 Opening a PDB in Read/Write Mode with the STARTUP Command and the FORCE Option
STARTUP FORCE
Example 42-14 Closing a PDB with the SHUTDOWN IMMEDIATE Command
SHUTDOWN IMMEDIATE
11) PDB 的 alter system 命令
PDB
中可執行如下
alter system
命令:
l
ALTER SYSTEM FLUSH SHARED_POOL
l
ALTER SYSTEM FLUSH BUFFER_CACHE
l
ALTER SYSTEM ENABLE RESTRICTED SESSION
l
ALTER SYSTEM DISABLE RESTRICTED SESSION
l
ALTER SYSTEM SET USE_STORED_OUTLINES
l
ALTER SYSTEM SUSPEND
l
ALTER SYSTEM RESUME
l
ALTER SYSTEM CHECKPOINT
l
ALTER SYSTEM CHECK DATAFILES
l
ALTER SYSTEM REGISTER
l
ALTER SYSTEM KILL SESSION
l
ALTER SYSTEM DISCONNECT SESSION
l
ALTER SYSTEM SET
initialization_parameter
(for a subset of initialization parameters)
# 查詢 PDB 中可以修改的引數
SELECT NAME FROM V$SYSTEM_PARAMETER WHERE ISPDB_MODIFIABLE='TRUE' ORDER BY NAME;
噹噹前容器是PDB時,執行ALTER SYSTEM SET initialization_parameter語句來修改PDB。該語句不影響root或其他PDBs。下表描述了當您使用伺服器引數檔案(SPFILE)並在PDB上執行ALTER SYSTEM SET語句時,SCOPE子句的行為。
SCOPE Setting |
Behavior |
|
The initialization parameter setting is changed in memory and takes effect immediately in the PDB. The new setting affects only the PDB. The setting reverts to the value set in the root in the any of the following cases:
·
An
· The PDB is closed and re-opened. · The CDB is shut down and re-opened. |
|
The initialization parameter setting is changed for the PDB and stored persistently. The new setting takes effect in any of the following cases: · The PDB is closed and re-opened. · The CDB is shut down and re-opened. In these cases, the new setting affects only the PDB. |
|
The initialization parameter setting is changed in memory, and it is changed for the PDB and stored persistently. The new setting takes effect immediately in the PDB and persists after the PDB is closed and re-opened or the CDB is shut down and re-opened. The new setting affects only the PDB. |
12) PDB 中的 service
在 PDB 中可以對 service 進行增、刪、改、查;
# 增:建立 service
srvctl add service -db mycdb -service salesrep -pdb salespdb
或者
BEGIN
DBMS_SERVICE.CREATE_SERVICE(
service_name => 'salesrep',
network_name => 'salesrep.example.com');
END;
/
# 改:修改 service
srvctl modify service -db mycdb -service salesrep -pdb hrpdb
不能透過DBMS_SERVICE包修改service,解決方法是刪除再建立;
# 刪:刪除 service
srvctl remove service -db mycdb -service salesrep
或
BEGIN
DBMS_SERVICE.DELETE_SERVICE(
service_name => 'salesrep');
END;
/
# 查,檢視 dba_services
在 Oracle RAC CDB 中的 PDB ,如果建立 service 時,指定了 -pdb 選項,啟動 service 資源時,同時也會 open 對應的 pdb ;使用 ALTER PLUGGABLE DATABASE 命令關閉 pdb 時, crs 資源 service 會自動 offline ,但是使用 ALTER PLUGGABLE DATABASE 命令啟動 pdb 時, service 資源不會隨之 online 啟動;
【參考】
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/16976507/viewspace-2639634/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 12c 檢視CDB&PDBs資訊(SQL*PLUS)OracleSQL
- Oracle 12c rac ocr和votedisk管理Oracle
- Oracle 12cOracle
- oracle 12c Deprecation of Oracle StreamsOracle
- Oracle 12c DG管理-分離SYS特權使用者Oracle
- Oracle 12C 中CDB和PDB的引數檔案管理Oracle
- Oracle 12C GDSOracle
- oracle 12c CDB企業管理器(EM Express)的配置方法OracleExpress
- 【12c Partitioning】Oracle 12c Partitioning特性Oracle
- Oracle 12C安裝Oracle
- Oracle 12c新特性Oracle
- Oracle 12c Relocate PDBOracle
- Oracle 12c Refreshable CloneOracle
- Oracle 12c RAC: MGMTDBOracle
- ORACLE 12C EM ExpressOracleExpress
- Oracle 12C配置EMOracle
- ORACLE 12c Core DocOracle
- Oracle 12c - Data RedactionOracle
- oracle 12c 釋出Oracle
- Oracle 12c升級指南Oracle
- 12C Oracle ASM Filter DriverOracleASMFilter
- Oracle 12c Automatic ReoptimizationOracle
- benchmark 壓測Oracle 12cOracle
- sysbench壓測Oracle 12COracle
- Oracle 12c 新特性(四)Oracle
- Oracle 12c 新特性(三)Oracle
- Oracle 12c 新特性(二)Oracle
- Oracle 12c 新特性(一)Oracle
- Oracle 12C dgbroker 配置Oracle
- Oracle 12c PDB淺析Oracle
- 12c 資料庫管理 小結資料庫
- Oracle Linux 7上安裝Oracle 12cOracleLinux
- Oracle 12C新特性-History命令Oracle
- Oracle 12c 兩個新特性Oracle
- Oracle 12C新特性In-MemoryOracle
- Oracle 12C 官方文件地圖Oracle地圖
- Oracle 12C Statistics on Column GroupsOracle
- oracle 12c release 2 安裝Oracle