Oracle Database 12C 基本操作一创建pdb

8 篇文章 0 订阅

pdb跟cdb关系:
这里写图片描述

pdb创建:

先决条件:
1 . cdb必须存在
2 . cdb处于可读写状态
3 . 当前用户属于公共用户切当前容器为root
4 . 当前用户有传经pdb权限
5 . 确定一个pdb唯一名称

Creating a PDB from the Seed :

这里写图片描述

CREATE PLUGGABLE DATABASE salespdb ADMIN USER salesadm IDENTIFIED BY password
  STORAGE (MAXSIZE 2G)
  DEFAULT TABLESPACE sales 
    DATAFILE '/disk1/oracle/dbs/salespdb/sales01.dbf' SIZE 250M AUTOEXTEND ON
  PATH_PREFIX = '/disk1/oracle/dbs/salespdb/'
  FILE_NAME_CONVERT = ('/disk1/oracle/dbs/pdbseed/', '/disk1/oracle/dbs/salespdb/');

‘FILE_NAME_CONVERT’参数是用来克隆pdb数据文件保存路径,如果设置了db_create_file_dest参数,这个参数就不用设置了。

Creating a PDB by Cloning an Existing PDB or Non-CDB:

通过克隆pdb或者non-pdb并添加到cdb,需要通过‘’from ‘’指定一个源,源可以使本地cdb或者 non-cdb,也可以是一个远程cdb或者non-cdb。

这里写图片描述

Example 1

Cloning a Local PDB Using No Clauses

CREATE PLUGGABLE DATABASE pdb2 FROM pdb1;
Example 2

Cloning a Local PDB With the PATH_PREFIX, FILE_NAME_CONVERT, and SERVICE_NAME_CONVERT Clauses

CREATE PLUGGABLE DATABASE pdb2 FROM pdb1 
  PATH_PREFIX = '/disk2/oracle/pdb2'
  FILE_NAME_CONVERT = ('/disk1/oracle/pdb1/', '/disk2/oracle/pdb2/')
  SERVICE_NAME_CONVERT = ('salesrep','salesperson','orders','orderentry')
  NOLOGGING;
Example 3

Cloning a Local PDB Using the FILE_NAME_CONVERT, STORAGE, and SERVICE_NAME_CONVERT Clauses

CREATE PLUGGABLE DATABASE pdb2 FROM pdb1 
  FILE_NAME_CONVERT = ('/disk1/oracle/pdb1/', '/disk2/oracle/pdb2/')
  STORAGE (MAXSIZE 2G)
  SERVICE_NAME_CONVERT = ('salesrep','salesperson','orders','orderentry');
Example 4

Cloning a Local PDB Without Cloning Its Data
1 .With the source PDB pdb1 as the current container, query a table with a large amount of data:

SELECT COUNT(*) FROM tpch.lineitem;

  COUNT(*)
----------
   6001215

The table has over six million rows.

2 . With the root as the current container, change the source PDB to open read-only mode:

ALTER PLUGGABLE DATABASE pdb1 OPEN READ ONLY;

3 . Clone the source PDB with the NO DATA clause:

CREATE PLUGGABLE DATABASE pdb2 FROM pdb1 NO DATA;

4 . Open the cloned PDB:

ALTER PLUGGABLE DATABASE pdb2 OPEN;

5 . With the cloned PDB pdb2 as the current container, query the table that has a large amount of data in the source PDB:

SELECT COUNT(*) FROM tpch.lineitem;

  COUNT(*)
----------
         0

The table in the cloned PDB has no rows.

Cloning a Remote PDB or Non-CDB

先决条件:
1 . 满足pdb创建先决条件;
2 . 当前用户在root容器和目标pdb有“CREATE PLUGGABLE DATABASE”权限,
3 . 源pdb或者源non-cdb必须以只读模式打开,
4 . 当克隆远程pdb时,你需要指定一个db_link 去访问远程cdb,这个db_link既可以访问远程root 容器,也能访问远程pdb容器。
5 . db_link 在源pdb或者non-cdb有“CREATE PLUGGABLE DATABASE”权限
6 . 如果 db_link 登录到远程cdb的root容器,那么db_link必须是一个公共账号。
7 . 源、目标系统架构需要满足如下:
. 相同的endianness
. The database options installed on the source platform must be the same as, or a subset of, the database options installed on the target platform.
8 . 有相同的字符集和扩展字符集
9 . 如果通过克隆non-cdb创建pdb,那么cdb和no-cdb必须有运行在12.1.0.2版本或之后。
这里写图片描述

Example 1 Creating a PDB by Cloning a Remote PDB Using No Clauses

This example clones a remote source PDB named pdb1 to a target PDB named pdb2 given different factors. This example assumes the following factors:


. The database link name to the remote PDB is pdb1_link.

. The PATH_PREFIX clause is not required.

. The FILE_NAME_CONVERT clause and the CREATE_FILE_DEST clause are not required.

Either Oracle Managed Files is enabled, or the PDB_FILE_NAME_CONVERT initialization parameter is set. The files will be copied to a new location based on the Oracle Managed Files configuration or the initialization parameter setting.

. Storage limits are not required for the PDB. Therefore, the STORAGE clause is not required.

. There is no file with the same name as the new temp file that will be created in the target location. Therefore, the TEMPFILE REUSE clause is not required.


Given the preceding factors, the following statement clones the pdb2 PDB from the pdb1 remote PDB:

CREATE PLUGGABLE DATABASE pdb2 FROM pdb1@pdb1_link;

当需要通过non-cdb克隆一个pdb,需要在non-cdb创建一个db_link。
这里写图片描述

Example 1 Creating a PDB by Cloning a Remote Non-CDB

This example creates a new PDB by cloning a remote source non-CDB named mydb to a target PDB named pdb2 given different factors. This example assumes the following factors:


. The database link name to the remote non-CDB is mydb_link.

. The PATH_PREFIX clause is not required.

. The FILE_NAME_CONVERT clause and the CREATE_FILE_DEST clause are not required.

Either Oracle Managed Files is enabled, or the PDB_FILE_NAME_CONVERT initialization parameter is set. The files will be copied to a new location based on the Oracle Managed Files configuration or the initialization parameter setting.

. Storage limits are not required for the PDB. Therefore, the STORAGE clause is not required.

. There is no file with the same name as the new temp file that will be created in the target location. Therefore, the TEMPFILE REUSE clause is not required.


Given the preceding factors, the following statement creates the pdb2 PDB from the remote non-CDB named mydb:

CREATE PLUGGABLE DATABASE pdb2 FROM mydb@mydb_link;

After Cloning a PDB:
If you created the PDB from a non-CDB, then run the ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql script. This script must be run before the PDB can be opened for the first time.

@$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql

. 克隆的pdb跟源库使用相同模式的临时表空间,如果源库使用的是磨人临时表空间或者手动指定临时表空间,克隆可也需要相同模式指定临时表空间。
.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值