So I am currently using my account with username: ctxsys and a password
In this account I have table named archiv11
.
In another account named d5a11
with a password I have a table called fileLocation
and what I am trying to do to make a foreign key from my current account table to the location table.
create table archiv11( id integer primary key, fileName varchar2(50), fileContent blob, locationID integer, CONSTRAINT archivFK FOREIGN KEY(locationID) REFERENCES d5a11.fileLocation(loc_ID) );
I get the error the table fileLocation does not exsist.
Is this possible?
Advertisement
Answer
No problem; owner of the referenced table has to grant REFERENCE
to another user, which has to precede referenced table name with its owner.
Here’s an example: user MIKE
has a table whose ID
is to be referenced in SCOTT
‘s table
SQL> show user USER is "MIKE" SQL> create table mike_table (id number primary key); Table created. SQL> grant references on mike_table to scott; Grant succeeded. SQL> connect scott/tiger Connected. SQL> create table scott_table (id number primary key, 2 id_mike number constraint fk_scmi references mike.mike_table(id) 3 ); Table created. SQL>