نکاتی در مورد PDB$SEED

می دانیم که در محیط Multitenant، برای ایجاد یک pdb جدید می توان از pdb فقط خواندنی و از پیش ساخته شده اوراکل که PDB$SEED نام دارد استفاده کرد. بعبارتی با اجرای دستور زیر، mypdb از روی PDB$SEED ایجاد خواهد شد:

SQL> create pluggable database mypdb admin user usef identified by u;

Pluggable database created.

توجه! ایجاد یک pdb می تواند از pdbهای دیگر موجود در بانک انجام شود و یا حتی می توان به صورت از راه دور، pdb را از pdb دیگری ایجاد نمود.

در مستندات اوراکل(حتی در Oracle 19c) می خوانیم که هرگونه اصلاح در pdb$seed امکان پذیر نمی باشد:

–Oracle 19c( E96136-01(2-4)):

You cannot drop PDB$SEED, or add objects to or modify objects within it.

این قاعده برای نسخه های قدیمی تر اوراکل صدق می کند(البته در حالت پیش فرض!) به طور مثال، در اوراکل 12cR1، اجرای هرگونه دستور alter بر روی pdb$seed امکان پذیر نخواهد بود:

SQL*Plus: Release 12.1.0.2.0 Production on Sun Feb 10 09:52:11 2019

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

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 – 64bit Production

With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> alter pluggable database PDB$SEED close;

ORA-65017: seed pluggable database may not be dropped or altered

برای اجرای دستور alter بر روی این pdb(در نسخه 12cR1)،  به ناچار باید به سراغ پارامتر مخفی oracle_script_ رفت:

SQL> alter session set “_oracle_script”=true;

Session altered.

SQL> alter pluggable database PDB$SEED close;

Pluggable database altered.

SQL> alter pluggable database PDB$SEED open read write;

Pluggable database altered.

SQL> alter session set container=PDB$SEED;

Session altered.

SQL> create user usef identified by a;

User created.

برخلاف انچه که در مستندات اوراکل ذکر شده است!!! در اوراکل نسخه 12cR2،ه 18c و 19c، دیگر نیازی به تنظیم پارامتر oracle_script_ نخواهد بود و امکان هرگونه تغییرات DMLای و DDLای(به جز حذف) بر روی این pdb و اشیاهای آن امکان پذیر خواهد بود:

SQL*Plus: Release 18.0.0.0.0 – Production on Sun Bahman 21 10:00:53 1397

Version 18.3.0.0.0

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

Connected to:

Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 – Production

Version 18.3.0.0.0

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

———- —————————— ———- ———-

         2 PDB$SEED                       MOUNTED

SQL> alter pluggable database PDB$SEED close;

Pluggable database altered.

SQL> alter pluggable database PDB$SEED open read write;

Pluggable database altered.

نمونه ای از اجرای دستور DDLای و DMLای را در این محیط ملاحظه می کنید:

SQL> alter session set container=PDB$SEED;

Session altered.

SQL> create user usef identified by a;

User created.

SQL> grant dba to usef;

Grant succeeded.

SQL> create table usef.tbl(id number);

Table created.

SQL> insert into usef.tbl values(1);

1 row created.

SQL> commit;

Commit complete.

 با ایجاد هرگونه تغییر در PDB$SEED،ه pdbهای جدید هم تغییرات جدید را به همراه خواهند داشت(صرفا pdbهای که از روی PDB$SEED ایجاد می شوند!):

SQL> create pluggable database pdb_test admin user reza identified by r;

Pluggable database created.

SQL> alter pluggable database pdb_test open;

Pluggable database altered.

SQL> alter session set container=pdb_test;

Session altered.

SQL> select count(*) from usef.tbl;

  COUNT(*)

———-

         1

با این وجود، برای حذف PDB$SEED کماکان باید از پارامتر مخفی oracle_script_ استفاده کرد:

SQL> drop pluggable database PDB$SEED including DATAFILES;

ORA-65017: seed pluggable database may not be dropped or altered

SQL> alter session set “_oracle_script”=true;

Session altered.

SQL> drop pluggable database PDB$SEED including DATAFILES;

Pluggable database dropped.

با حذف PDB$SEED، بدیهی خواهد بود که امکان ایجاد pdb جدید از روی PDB$SEED از بین خواهد رفت:

SQL> create pluggable database mynewpdb  admin user ali identified by a;

ORA-65011: Pluggable database PDB$SEED does not exist.

برای این کار می توان مجددا PDB$SEED را از روی pdbهای دیگر موجود در بانک ایجاد کرد:

SQL>  create pluggable database PDB$SEED from pdb1;

Pluggable database created.

PDB$SEED جدید برای دیتابیس، مشابه با همان PDB$SEED قبل از حذف خواهد بود:

SQL> drop pluggable database PDB$SEED including DATAFILES;

ORA-65017: seed pluggable database may not be dropped or altered

SQL> alter pluggable database PDB$SEED open ;

Pluggable database altered.

SQL>  create pluggable database mynewpdb  admin user ali identified by a;

Pluggable database created.

ارائه خدمات مشاوره ، پشتیبانی و نصب و راه اندازی پایگاه داده اوراکل در سراسر کشور...................... تلفن: 09128110897 ایمیل:vahidusefzadeh@gmail.com

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *