How to make a foreign key on a different account











up vote
0
down vote

favorite












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?










share|improve this question






















  • You need read access to the table in order to define a foreign key relationship to it.
    – Gordon Linoff
    yesterday















up vote
0
down vote

favorite












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?










share|improve this question






















  • You need read access to the table in order to define a foreign key relationship to it.
    – Gordon Linoff
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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?










share|improve this question













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?







sql database oracle foreign-keys






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









kokos123

759




759












  • You need read access to the table in order to define a foreign key relationship to it.
    – Gordon Linoff
    yesterday


















  • You need read access to the table in order to define a foreign key relationship to it.
    – Gordon Linoff
    yesterday
















You need read access to the table in order to define a foreign key relationship to it.
– Gordon Linoff
yesterday




You need read access to the table in order to define a foreign key relationship to it.
– Gordon Linoff
yesterday












2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










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>





share|improve this answer




























    up vote
    0
    down vote













    This should be possible. However you must permit it with



    grant reference on d5a11.fileLocation to ctxsys;





    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401780%2fhow-to-make-a-foreign-key-on-a-different-account%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote



      accepted










      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>





      share|improve this answer

























        up vote
        1
        down vote



        accepted










        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>





        share|improve this answer























          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          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>





          share|improve this 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>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          Littlefoot

          18.1k51333




          18.1k51333
























              up vote
              0
              down vote













              This should be possible. However you must permit it with



              grant reference on d5a11.fileLocation to ctxsys;





              share|improve this answer

























                up vote
                0
                down vote













                This should be possible. However you must permit it with



                grant reference on d5a11.fileLocation to ctxsys;





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  This should be possible. However you must permit it with



                  grant reference on d5a11.fileLocation to ctxsys;





                  share|improve this answer












                  This should be possible. However you must permit it with



                  grant reference on d5a11.fileLocation to ctxsys;






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  Wernfried Domscheit

                  23.4k42757




                  23.4k42757






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401780%2fhow-to-make-a-foreign-key-on-a-different-account%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Berounka

                      Sphinx de Gizeh

                      Different font size/position of beamer's navigation symbols template's content depending on regular/plain...