SlideShare uma empresa Scribd logo
1 de 4
Baixar para ler offline
Articles from Database administrator
workshop
How to change the open mode of all pluggable
databases
When you need to modify the open mode of all your PDBs at the same time (look at
this post if you want to change the open mode of only a specific pluggable database)
you can use ALTER PLUGGABLE DATABASE command and the ALL option.
As usual you have to ensure that the current container is the root.
view plainprint?
1. SQL> SELECT SYS_CONTEXT ('USERENV', 'CON_NAME') FROM DUAL;
2.
3. SYS_CONTEXT('USERENV','CON_NAME')
4. --------------------------------------------------------------------------------
5. CDB$ROOT
The following statement for example changes the open mode of all your pluggable
databases at the same time.
view plainprint?
1. SQL>ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE;
2.
3. Pluggable database altered.
4.
5. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
6.
7. NAME OPEN_MODE CON_ID
8. ------------------------------ ---------- ----------
9. PDB$SEED READ ONLY 2
10. PDB001 MOUNTED 3
11. PDB002 MOUNTED 4
When you need to change the open mode of all pluggable database except for listed
ones you can include also the EXCEPT option as in the following example:
view plainprint?
1. SQL> ALTER PLUGGABLE DATABASE ALL EXCEPT PDB001 OPEN READ WRITE;
2.
3. Pluggable database altered.
4.
5. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
6.
7. NAME OPEN_MODE CON_ID
8. ------------------------------ ---------- ----------
9. PDB$SEED READ ONLY 2
10. PDB001 MOUNTED 3
11. PDB002 READ WRITE 4
To open all my pluggable databases I can simply execute the following command. It
doesn't take care that PDB002 is already open in READ WRITE mode: any error is
returned because the pluggable databases are in different open mode.
view plainprint?
1. SQL> ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE;
2.
3. Pluggable database altered.
4.
5. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
6.
7. NAME OPEN_MODE CON_ID
8. ------------------------------ ---------- ----------
9. PDB$SEED READ ONLY 2
10. PDB001 READ WRITE 3
11. PDB002 READ WRITE 4
However, if any of your pluggable databases are in READ ONLY mode, then the
statement returns the error "ORA-65019: pluggable database PDB001 already
open" as you can see:
view plainprint?
1. SQL> ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE;
2.
3. Pluggable database altered.
4.
5. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
6.
7. NAME OPEN_MODE CON_ID
8. ------------------------------ ---------- ----------
9. PDB$SEED READ ONLY 2
10. PDB001 MOUNTED 3
11. PDB002 MOUNTED 4
12.
13. SQL> ALTER PLUGGABLE DATABASE PDB001 OPEN READ ONLY;
14.
15. Pluggable database altered.
16.
17. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
18.
19. NAME OPEN_MODE CON_ID
20. ------------------------------ ---------- ----------
21. PDB$SEED READ ONLY 2
22. PDB001 READ ONLY 3
23. PDB002 MOUNTED 4
24.
25. SQL> ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE;
26. ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE
27. *
28. ERROR at line 1:
29. ORA-65019: pluggable database PDB001 already open
Even if the statement fails for pluggable database PDB001 it was able to open
PDB002 as requested:
view plainprint?
1. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
2.
3. NAME OPEN_MODE CON_ID
4. ------------------------------ ---------- ----------
5. PDB$SEED READ ONLY 2
6. PDB001 READ ONLY 3
7. PDB002 READ WRITE 4
To avoid the error ORA-65019 you can include the FORCE option in your
command:
view plainprint?
1. SQL> ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE FORCE;
2.
3. Pluggable database altered.
4.
5. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
6.
7. NAME OPEN_MODE CON_ID
8. ------------------------------ ---------- ----------
9. PDB$SEED READ ONLY 2
10. PDB001 READ WRITE 3
11. PDB002 READ WRITE 4
To shutdown all your pluggable databases except one you can use the following
command:
view plainprint?
1. SQL> alter pluggable database all except PDB002 close immediate;
2.
3. Pluggable database altered.
4.
5. SQL> select name, open_mode from V$PDBS;
6.
7. NAME OPEN_MODE
8. ------------------------------ ----------
9. PDB$SEED READ ONLY
10. PDB001 MOUNTED
11. PDB002 READ WRITE
To list some of your pluggable databases you can use the comma as in the
following example where I need to open all my pluggable databases (PDB001 and
PDB002) except those listed (just PDB001 and PDB002!!). Nothing happens of
course.
view plainprint?
1. SQL> alter pluggable database all except PDB002,PDB001 open;
2.
3. Pluggable database altered.
4.
5. SQL> select name, open_mode from V$PDBS;
6.
7. NAME OPEN_MODE
8. ------------------------------ ----------
9. PDB$SEED READ ONLY
10. PDB001 MOUNTED
11. PDB002 READ WRITE
That's all.

Mais conteúdo relacionado

Destaque

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

How to change the open mode of all pluggable databases

  • 1. Articles from Database administrator workshop How to change the open mode of all pluggable databases When you need to modify the open mode of all your PDBs at the same time (look at this post if you want to change the open mode of only a specific pluggable database) you can use ALTER PLUGGABLE DATABASE command and the ALL option. As usual you have to ensure that the current container is the root. view plainprint? 1. SQL> SELECT SYS_CONTEXT ('USERENV', 'CON_NAME') FROM DUAL; 2. 3. SYS_CONTEXT('USERENV','CON_NAME') 4. -------------------------------------------------------------------------------- 5. CDB$ROOT The following statement for example changes the open mode of all your pluggable databases at the same time. view plainprint? 1. SQL>ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE; 2. 3. Pluggable database altered. 4. 5. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS; 6. 7. NAME OPEN_MODE CON_ID 8. ------------------------------ ---------- ---------- 9. PDB$SEED READ ONLY 2 10. PDB001 MOUNTED 3 11. PDB002 MOUNTED 4 When you need to change the open mode of all pluggable database except for listed ones you can include also the EXCEPT option as in the following example: view plainprint? 1. SQL> ALTER PLUGGABLE DATABASE ALL EXCEPT PDB001 OPEN READ WRITE; 2. 3. Pluggable database altered. 4. 5. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS; 6. 7. NAME OPEN_MODE CON_ID 8. ------------------------------ ---------- ---------- 9. PDB$SEED READ ONLY 2 10. PDB001 MOUNTED 3 11. PDB002 READ WRITE 4
  • 2. To open all my pluggable databases I can simply execute the following command. It doesn't take care that PDB002 is already open in READ WRITE mode: any error is returned because the pluggable databases are in different open mode. view plainprint? 1. SQL> ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE; 2. 3. Pluggable database altered. 4. 5. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS; 6. 7. NAME OPEN_MODE CON_ID 8. ------------------------------ ---------- ---------- 9. PDB$SEED READ ONLY 2 10. PDB001 READ WRITE 3 11. PDB002 READ WRITE 4 However, if any of your pluggable databases are in READ ONLY mode, then the statement returns the error "ORA-65019: pluggable database PDB001 already open" as you can see: view plainprint? 1. SQL> ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE; 2. 3. Pluggable database altered. 4. 5. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS; 6. 7. NAME OPEN_MODE CON_ID 8. ------------------------------ ---------- ---------- 9. PDB$SEED READ ONLY 2 10. PDB001 MOUNTED 3 11. PDB002 MOUNTED 4 12. 13. SQL> ALTER PLUGGABLE DATABASE PDB001 OPEN READ ONLY; 14. 15. Pluggable database altered. 16. 17. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS; 18. 19. NAME OPEN_MODE CON_ID 20. ------------------------------ ---------- ---------- 21. PDB$SEED READ ONLY 2 22. PDB001 READ ONLY 3 23. PDB002 MOUNTED 4 24. 25. SQL> ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE; 26. ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE 27. * 28. ERROR at line 1: 29. ORA-65019: pluggable database PDB001 already open Even if the statement fails for pluggable database PDB001 it was able to open
  • 3. PDB002 as requested: view plainprint? 1. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS; 2. 3. NAME OPEN_MODE CON_ID 4. ------------------------------ ---------- ---------- 5. PDB$SEED READ ONLY 2 6. PDB001 READ ONLY 3 7. PDB002 READ WRITE 4 To avoid the error ORA-65019 you can include the FORCE option in your command: view plainprint? 1. SQL> ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE FORCE; 2. 3. Pluggable database altered. 4. 5. SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS; 6. 7. NAME OPEN_MODE CON_ID 8. ------------------------------ ---------- ---------- 9. PDB$SEED READ ONLY 2 10. PDB001 READ WRITE 3 11. PDB002 READ WRITE 4 To shutdown all your pluggable databases except one you can use the following command: view plainprint? 1. SQL> alter pluggable database all except PDB002 close immediate; 2. 3. Pluggable database altered. 4. 5. SQL> select name, open_mode from V$PDBS; 6. 7. NAME OPEN_MODE 8. ------------------------------ ---------- 9. PDB$SEED READ ONLY 10. PDB001 MOUNTED 11. PDB002 READ WRITE To list some of your pluggable databases you can use the comma as in the following example where I need to open all my pluggable databases (PDB001 and PDB002) except those listed (just PDB001 and PDB002!!). Nothing happens of course. view plainprint? 1. SQL> alter pluggable database all except PDB002,PDB001 open; 2. 3. Pluggable database altered. 4. 5. SQL> select name, open_mode from V$PDBS;
  • 4. 6. 7. NAME OPEN_MODE 8. ------------------------------ ---------- 9. PDB$SEED READ ONLY 10. PDB001 MOUNTED 11. PDB002 READ WRITE That's all.