I appreciate your cooperation with the following situation. I have two different databases (ex: orcl1
and orcl2
), the database orcl1
has multiple user-schemas ( esquema1
, esquema2
), the database orcl2
has one user-schema usrdb
. I must give permissions so that the usrdb
database user orcl2
can do crud
on the tables of the schemas esquema1
and esquema2
of the database orcl1
. The question I have is how can I grant those permissions between database users?
The short answer is: you can't grant privileges to a user of another database in oracle.
Making this answer longer:
This does not mean that someone connected to a database cannot modify information that resides in another database, simply that they must use an authentication mechanism controlled by what is known as db links . In essence, the db-link defines the connection parameters to the database and the way to authenticate in it, which can be through a username and password that are stored in the db link ; ie: all users of database A, will appear as the same user when performing operations on database B, or it can be the
CURRENT USER
.The simplest is the first one, for example, on the host where your database is
Orcl2
, you configure a TNS alias with the parameters ofOrcl1
and execute this instruction:In the Orcl1 database there must exist the user Orcl2User and its password Orcl2Password .
From there, all Orcl2 users will be able to access Orcl1 objects with Orcl2User permissions, for example, do:
If that's not enough for you, then let's talk about database links for the
CURRENT USER
:In this case, the users must be global users that must exist in both databases (LDAP).
Creating the database link is like this:
Usage is the same, but this time, each user will have their own privileges (which are granted locally on each database, since users exist in both).
For more information, visit the documentation for the clause
GLOBALLY
,create user
which is supplemented by the Defining a CURRENT_USER Database Link example from the documentation forCREATE DATABASE LINK