I bet you heard about ORACLE_PDB_SID, right? But do you know how it works?

This one is more on a curious side =) but somehow interesting.

Not too long ago Mike Dietrichde published a post on to connect directly to a PDB without a password.

After it, lots of DBAs started to post their testing showing the same, But how it works? As there is only a bequeath connection available to a CDB?

Well, I was doing some digging for another project and stumbled on a curious thing. A logon trigger called DBMS_SET_PDB

To my surprise, this trigger alters the session´s container to the one specified by the ORACLE_PDB_SID variable. Similar to Tanel Poder´s script called cc.sql or ccr.sql which basically are short cuts to avoid a lot of typing =)

SYS@CDB19c>select
DBMS_Metadata.Get_DDL('TRIGGER',t.trigger_name,t.owner)
From
DBA_Triggers t
Where
TRIGGER_NAME ='DBMS_SET_PDB'; 2 3 4 5 6

DBMS_METADATA.GET_DDL('TRIGGER',T.TRIGGER_NAME,T.OWNER)
--------------------------------------------------------------------------------

CREATE OR REPLACE NONEDITIONABLE TRIGGER "SYS"."DBMS_SET_PDB" after logon on database
WHEN (user = 'SYS' or user = 'SYSTEM') declare
pdb_name varchar2(64);
begin
DBMS_SYSTEM.get_env ('ORACLE_PDB_SID', pdb_name);
if(pdb_name is not null)
then
EXECUTE IMMEDIATE 'alter session set container = ' || '"' || pdb_name
|| '"';
end if;
exception
when others then
NULL;
end dbms_set_pdb;
ALTER TRIGGER "SYS"."DBMS_SET_PDB" ENABLE

Also is mentioned in the article that this is this would only work on versions 18.8 and above. But well, as we have the code for the trigger, should it possible to work on 12c as well?

Let´s try it| =) the oldest container which I have at the moment is 12r2  but that should do it.

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

SYS@CDB12CR2>select * from v$version;

BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
PL/SQL Release 12.2.0.1.0 - Production 0
CORE 12.2.0.1.0 Production 0
TNS for Linux: Version 12.2.0.1.0 - Production 0
NLSRTL Version 12.2.0.1.0 - Production 0

SYS@CDB12CR2>CREATE OR REPLACE NONEDITIONABLE TRIGGER "SYS"."DBMS_SET_PDB_EFA" after logon on database
2 WHEN (user = 'SYS' or user = 'SYSTEM') declare
3 pdb_name varchar2(64);
begin
4 5 DBMS_SYSTEM.get_env ('ORACLE_PDB_SID', pdb_name);
6 if(pdb_name is not null)
7 then
8 EXECUTE IMMEDIATE 'alter session set container = ' || '"' || pdb_name
9 || '"';
10 end if;
exception
when others then
NULL;
end DBMS_SET_PDB_EFA; 11 12 13 14
15 /

Trigger created.

SYS@CDB12CR2>ALTER TRIGGER "SYS"."DBMS_SET_PDB_EFA" ENABLE
2 /

Trigger altered.

SYS@CDB12CR2>show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB12CR2 READ WRITE NO
SYS@CDB12CR2>exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@server01 ~]$ export ORACLE_PDB_SID=PDB12CR2;
[oracle@server01 ~]$ CDB12CR2
The Oracle base remains unchanged with value /oraadm/oracle
LD_LIBRARY_PATH=/oraadm/oracle/product/12.2.0.1/lib
ORACLE_BASE=/oraadm/oracle
ORACLE_HOME=/oraadm/oracle/product/12.2.0.1
ORACLE_PDB_SID=PDB12CR2
ORACLE_SID=CDB12CR2
ORAENV_ASK=NO

[oracle@server01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jul 30 11:30:34 2020

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


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

SYS@CDB12CR2>show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 PDB12CR2 READ WRITE NO
SYS@CDB12CR2>alter session set container=cdb$root;

Session altered.

SYS@CDB12CR2>show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB12CR2 READ WRITE NO
SYS@CDB12CR2>

And as you can see, the trigger works as expected right, it’s not a rocket science as it gets the context environment variable value and alters the session´s container.

Thanks and until next time.

Cheers.

Elisson Almeida

 

Note:

Right after I wrote this post, I went to look for more information on ORACLE_PDB_SID and found another post from Mike Dietrichde which also shows the trigger code and some pitfalls that you must be aware.

LAOUC 2020: DevOps: PLSQL Development Best Practices for DBAs

Hi all!

This year I’ll be again speaking on the LAOUC (Latin America Oracle User Community) Groundbreakers Tour with a new topic: “DevOps: PLSQL Development Best Practices for DBAs“.

Different from the previous years, on this edition, we’ll have a consolidated agenda of conferences, instead of the tour on the continent. So we’ll have people speaker all sorts of languages all day long during the week of the conference, from August 17th to August 21th.

I’ll be speaking on the first day, as per states my card below.

Complete agenda: http://www.laouc.org/2020/06/29/oracle-groundbreakers-tour-2020-latam/

Details about my session: http://www.laouc.org/equipo/795/

Subscribe to my session! 

MatheusLAOUC

See you there!

grepOra 2.0 is Online! What’s New?

Hi all!

We are glad to announce our version 2.0 is online!

We have been working with the same blog layout since 2015, as being we HAD to make a few improvements to accommodate all changes we had on our structure and also some things to make YOUR experience even better.

We did try to keep the layout as clean as possible, as you are used to. In case you find any big issue, broken link or similar, let us know!

WHAT’S NEW?

1. The HOME page:

  • We made some quick buttons for the main features and we hope you like it!
  • We have now a quick panel with the latest posts on our main categories.

NewScreenshot 2020-07-28 às 15.12.46

2. The AGENDA

  • We know some of you get annoyed about the number of events we announce on the blog feed.
  • However, we know some of you come here specifically for this.
  • To accommodate both, we have set an AGENDA to have in a much more modern fashion the list of upcoming events from either the Community around the Globe and also Oracle official events and webinars.
  • We are still getting things around and you’ll keep seeing improvements in this regard soon!
  • You have now the LIST and SCHEDULE view too!

NewScreenshot 2020-07-28 às 18.16.42

NewScreenshot 2020-07-28 às 18.18.10

3. The FORUM

  • YES! You have now an open Forum to ask quick questions and have answers not only from the Authors but from the whole community. ENJOY and USE IT!
  • I have filled with some questions I heard recently and answers, just as an example. But we await YOUR interaction there!

NewScreenshot 2020-07-28 às 18.20.37

 

4. A LEARNING Space

  • As many of you asked, we started a learning space where we recommend some of the books and trainings we have read/tested/validated/like for your development.
  • Among the items we have on the roadmap is start including reviews on trainings and books.
  • By buying the books from the given links you’ll be helping grepOra to keep alive and growing. Thanks!
  • You can expect new sessions, recommendations and reviews soon!

NewScreenshot 2020-07-28 às 18.23.59

 

There are of course tons of quick and tiny improvements here and there all over the pages and spaces. We have rebuilt ALL the pages, like the MEMBERS page. But those are the 4 main improvements.

You can expect for more soon:

  • A Monthly Newsletter will start soon. Subscribe yourself and stay sharp!
  • Book and Trainings Reviews will start to be published soon.
  • The Agenda will become more integrated and have additional sources soon.
  • Expect for more surprises soon!

 

We are glad to have you here. This is all for YOU!

I want to take some space here to also thank Gabriel Morás and Jociéli Maleico for helping out on this reimagination process. Thank you!

Thank you and Enjoy!

 

 

GUORS Webinar: Automating Daily DBA Tasks with Ansible? [PT-BR]

Sem MIMIMI, você está realmente usando o que Ansible pra melhorar a sua eficiência ou é só pro chefe ver?

No próximo dia 23/7 as 19:00 o Ricardo Martins estará apresentando um case real de como utilizar o Ansible para automatizar as suas atividades.

É gratuito! Basta inscrever-se aqui: https://guorsiiencontro2020.eventize.com.br

WhatsApp Image 2020-06-23 at 18.35.47 (1)

Appreciation Note: YATRA 2020 Online + Tips and Trick from 20k+ Hours Oncall

Hi all!

First of all, it’s not over! We still have great sessions going on on the Yatra Online, check them HERE!

Before going through it, for the regular grepOra readers: you know I use to make reviews about events. But this is not a simple review, is an appreciation not for the AIOUG members and organization for such a great organization and engagement.

So this post is about my participation in this year’s edition, which has ended at this point. In topics:

1) Meet & Greet with Oracle ACE/GA/JC Community Session

It was a great pleasure to be speaking about the Oracle Community Programs with my fellow colleagues and friends Biju Thomas, Liron Amitzi and Basheer Khan last Saturday!

Thank you guys and AIOUG for the partnership and for the great discussions and motivation burst!

2) Tips & Tricks from 20K+ hours DBA oncall,

Let’s say the main item of this list, my session delivered yesterday. Such a great pleasure and a marvelous audience! We feel really glad and useful when we see a lot of questions and contributions. I’d like to say a warm and personal thank you for all the about 180 who attended this session and say it was a great experience for me!

My Slides are available here!
Along with the rest of my other conference slides, here.

About the questions: I was able to answer 10-12 questions during the conference session, but there were more not replied. I’m awaiting the organization to send me the list of all questions and I’ll make a new blog post dedicated to it. Stay sharp!

NOTE: I big thanks to Jure Bratina for pointing out an issue with the slides (regarding /*+ GATHER_PLAN_STATISTICS */). It is fixed!

3) Interview with Jim Grisanzio (Oracle Community)

Last but not least, I just had an interview with Jim Grisanzio for the YATRA Tour Online series. I can only say it was a pleasure and an honor to talk a bit with Jim on behalf of the Oracle Community in APAC about the ACE Program, career, Community in general, and about my session on this Yatra. Have a look and leave a LIKE if you enjoyed it!

 

Final Notes

I know Yatra means “Journey”. So what a great Journey we are having with all the awesome names and sessions, from which I could attend just a few because of my shift limitations. I’m sure we’ll all meet and repeat this experience in person really soon!

In this while, I’d like to use this opportunity to thank:

  • Sai Penumuru and Aishwarya Kala on behalf of the AIOUG team: Such a great event you are hosting! Congratulations on your organization, professionalism, and quality material and speakers. Well done!
  • All ACE Community to allow us to be in such great events, and specifically Biju, Liron and Basheer for the good and friendly conversation on Saturday.
  • Jim and the great conversation as you can see in the video above.
  • Especially and mostly to the whole Indian Community for the great reception and engagement. Thank you and congratulations!

Some memories I keep from this Yatra’s edition:

YATRA 2020: Meet & Greet with Oracle ACE/GA/JC Community Session – It’s Tomorrow!

Hi all,

Just a reminder to you all about tomorrow’s session!

I’ll be sharing about the community engagements and career with the friends Biju Thomas, Liron Amitzi and Basheer Khan on the 3rd and last session of Meet, Greet, Chat with Oracle ACE Directors and Groundbreaker Ambassadors at Yatra 2020 Online!

Click on the image below to register and attend or through this link: https://www.aioug.org/ogyatra-2020?day=11#

yatraonline

See you there!

Webinar: Automating Daily DBA Tasks with Ansible? [PT-BR]

Ansible está em voga. Mas você além de falar sobre, você está efetivamente usando de forma eficiente no seu ambiente?

No próximo dia 23/7 as 19:00 o Ricardo Martins estará apresentando um case real de como utilizar o Ansible para automatizar as suas atividades.

É gratuito! Basta inscrever-se aqui: https://guorsiiencontro2020.eventize.com.br/?preview

WhatsApp Image 2020-06-23 at 18.35.47