Question

I have several store procedures, which analyze oracle logs using log miner. These procedures run on CDB user C##ADMIN which created for this manner.

Now I want to compare the logged values to the live values, so I need to be able to access each pdb from the CDB.

After several searches, I came across database link which looks like a possible answer. but when I'm trying to create a database link it says ORA-02011: duplicate database link name. and when I'm trying to drop it I'm getting ORA-65230: internal database link cannot be altered or dropped.

I'm tried to run the following queries, but it failed: (even when connected as: / as sysdba)

SELECT * FROM ALL_TABLES@testpdb; 

ORA-12541: TNS:no listener
*Cause: The connection request could not be completed because the listener 
      is not running.
*Action: Ensure that the supplied destination address matches one of 
      the addresses used by the listener - compare the TNSNAMES.ORA entry with 
      the appropriate LISTENER.ORA file (or TNSNAV.ORA if the connection is to 
      go by way of an Interchange). Start the listener on the remote machine.

SELECT * FROM test.TABLE1@testpdb;   

ORA-12541: TNS:no listener
*Cause: The connection request could not be completed because the listener 
      is not running.
*Action: Ensure that the supplied destination address matches one of 
      the addresses used by the listener - compare the TNSNAMES.ORA entry with 
      the appropriate LISTENER.ORA file (or TNSNAV.ORA if the connection is to 
      go by way of an Interchange). Start the listener on the remote machine.

So my questions are:

  • Is using database links is it the correct way?
  • If it is, how to configure it?
  • How can I use it?
  • Do I have any alternative to achieve my goal?
Was it helpful?

Solution

That error means your listener is not running. Start your listener.

This just works normally without doing anything:

SQL> create user c##myadmin identified by password;

User created.

SQL> grant dba to c##myadmin container=all;

Grant succeeded.

SQL> alter user c##myadmin set container_data=all container=current;

User altered.

SQL> conn c##myadmin/password
Connected.
SQL> select con_id, name from v$containers;

    CON_ID NAME
---------- ----------
         1 CDB$ROOT
         2 PDB$SEED
         3 PDB1
         4 PDB2

SQL> select count(*) from dba_users@pdb1;

  COUNT(*)
----------
        37

SQL> select count(*) from dba_users@pdb2;

  COUNT(*)
----------
        37

SQL> select db_link from dba_db_links;

DB_LINK
--------------------------------------------------------------------------------
SYS_HUB

An alternative is the CONTAINERS clause, but that has some serious limitations (queried object must exist in all containers).

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top