Steps on creating a new PDB service


Setting up a new service in a Pluggable Database (PDB) in Oracle involves creating the service in the PDB and configuring the client to connect to it. 


Steps:

1. Login to container Database and Change to pdb container;

sqlplus '/as sysdba'
alter session set container=pdb1;

2. Create service for current pdb using name and new network service name.

Syntax:
BEGIN
   DBMS_SERVICE.CREATE_SERVICE(
      service_name => 'MY_PDB_SERVICE',
      network_name => 'MY_PDB_SERVICE'
   );
END;
/

exec dbms_service.create_service('pdb1','pdb1');

3. Start the new service.

exec dbms_service.start_service('pdb1');

alter system register;

4. Check the listener services and try to make a new connection to the newly created services. 
lsnrctl services 

SELECT NAME FROM V$ACTIVE_SERVICES;


5. Save the state for PDB. Need to save the state for pluggable for the new pdb service. Otherwise, you need to manually start the service after you restart the pdb or bounce the CDB ROOT database.

alter pluggable database save state;


Try now the connection with new service name.

6. Add need TNS entry as needed.

 TNS  
 new_service=  
  (DESCRIPTION=  
   (ADDRESS=  
    (PROTOCOL=TCP)  
    (HOST=10.10.10.10)  
    (PORT=1521)  
   )  
   (CONNECT_DATA=  
    (SERVER=dedicated)  
    (SERVICE_NAME=pdb1)  
   )  
  ) 

Stop or Delete the Service (if needed):

Stop the service:

EXEC DBMS_SERVICE.STOP_SERVICE('PDB1');

Delete the service:

BEGIN
   DBMS_SERVICE.DELETE_SERVICE('PDB1');
END;
/



Please do like and subscribe to my youtube channel: https://www.youtube.com/@foalabs If you like this post please follow,share and comment