Error creating Oracle table invalid identifier










1















I'm trying to create a table in Oracle 11g, but got ORA-00904 error. The syntax for creating the table is:



CREATE TABLE Worker(
nif VARCHAR2(9 CHAR) CONSTRAINT PK_Nif PRIMARY KEY,
nameworker VARCHAR2(50 CHAR) CONSTRAINT NN_NameWorker NOT NULL,
specialty VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,
CONSTRAINT CH_Speciality CHECK (speciality ='ENGINEERING' OR speciality= 'SUPPORT' OR speciality='DEVELOPMENT'),
yearsold INTEGER,
CONSTRAINT CH_Years CHECK (yearsold >= 1),
CONSTRAINT NN_Years NOT NULL,
nifCompany VARCHAR2(9 CHAR) CONSTRAINT NN_NifCompany NOT NULL,
CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif)
);


And the error I got is:




ORA-00904: : invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:



I don't know where the error is.










share|improve this question




























    1















    I'm trying to create a table in Oracle 11g, but got ORA-00904 error. The syntax for creating the table is:



    CREATE TABLE Worker(
    nif VARCHAR2(9 CHAR) CONSTRAINT PK_Nif PRIMARY KEY,
    nameworker VARCHAR2(50 CHAR) CONSTRAINT NN_NameWorker NOT NULL,
    specialty VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,
    CONSTRAINT CH_Speciality CHECK (speciality ='ENGINEERING' OR speciality= 'SUPPORT' OR speciality='DEVELOPMENT'),
    yearsold INTEGER,
    CONSTRAINT CH_Years CHECK (yearsold >= 1),
    CONSTRAINT NN_Years NOT NULL,
    nifCompany VARCHAR2(9 CHAR) CONSTRAINT NN_NifCompany NOT NULL,
    CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif)
    );


    And the error I got is:




    ORA-00904: : invalid identifier
    00904. 00000 - "%s: invalid identifier"
    *Cause:
    *Action:



    I don't know where the error is.










    share|improve this question


























      1












      1








      1








      I'm trying to create a table in Oracle 11g, but got ORA-00904 error. The syntax for creating the table is:



      CREATE TABLE Worker(
      nif VARCHAR2(9 CHAR) CONSTRAINT PK_Nif PRIMARY KEY,
      nameworker VARCHAR2(50 CHAR) CONSTRAINT NN_NameWorker NOT NULL,
      specialty VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,
      CONSTRAINT CH_Speciality CHECK (speciality ='ENGINEERING' OR speciality= 'SUPPORT' OR speciality='DEVELOPMENT'),
      yearsold INTEGER,
      CONSTRAINT CH_Years CHECK (yearsold >= 1),
      CONSTRAINT NN_Years NOT NULL,
      nifCompany VARCHAR2(9 CHAR) CONSTRAINT NN_NifCompany NOT NULL,
      CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif)
      );


      And the error I got is:




      ORA-00904: : invalid identifier
      00904. 00000 - "%s: invalid identifier"
      *Cause:
      *Action:



      I don't know where the error is.










      share|improve this question
















      I'm trying to create a table in Oracle 11g, but got ORA-00904 error. The syntax for creating the table is:



      CREATE TABLE Worker(
      nif VARCHAR2(9 CHAR) CONSTRAINT PK_Nif PRIMARY KEY,
      nameworker VARCHAR2(50 CHAR) CONSTRAINT NN_NameWorker NOT NULL,
      specialty VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,
      CONSTRAINT CH_Speciality CHECK (speciality ='ENGINEERING' OR speciality= 'SUPPORT' OR speciality='DEVELOPMENT'),
      yearsold INTEGER,
      CONSTRAINT CH_Years CHECK (yearsold >= 1),
      CONSTRAINT NN_Years NOT NULL,
      nifCompany VARCHAR2(9 CHAR) CONSTRAINT NN_NifCompany NOT NULL,
      CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif)
      );


      And the error I got is:




      ORA-00904: : invalid identifier
      00904. 00000 - "%s: invalid identifier"
      *Cause:
      *Action:



      I don't know where the error is.







      oracle identifier






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 10:07









      mx0

      2,78482633




      2,78482633










      asked Nov 13 '18 at 10:03









      llinasencllinasenc

      61




      61






















          2 Answers
          2






          active

          oldest

          votes


















          1














          You have a couple of problems; the immediate cause of the error is this line:



          CONSTRAINT NN_Years NOT NULL,


          which based on the earlier naming you probably meant to include inline with the column definition:



          yearsold INTEGER CONSTRAINT NN_Years NOT NULL,
          CONSTRAINT CH_Years CHECK (yearsold >= 1),


          The second problem is that you've got inconsistent names, specialty in the column definition vs. speciality in the check constraint; so you need to fix the column and not-null constraint names:



          speciality VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,


          Fixing those things, and assuming you do have a Company table with a matching PK for the FK this specifies, gives you:



          CREATE TABLE Worker(
          nif VARCHAR2(9 CHAR) CONSTRAINT PK_Nif PRIMARY KEY,
          nameworker VARCHAR2(50 CHAR) CONSTRAINT NN_NameWorker NOT NULL,
          speciality VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,
          CONSTRAINT CH_Speciality CHECK (speciality = 'ENGINEERING'
          OR speciality = 'SUPPORT' OR speciality = 'DEVELOPMENT'),
          yearsold INTEGER CONSTRAINT NN_Years NOT NULL,
          CONSTRAINT CH_Years CHECK (yearsold >= 1),
          nifCompany VARCHAR2(9 CHAR) CONSTRAINT NN_NifCompany NOT NULL,
          CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif)
          );

          Table WORKER created.

          desc worker

          Name Null? Type
          ---------- -------- -----------------
          NIF NOT NULL VARCHAR2(9 CHAR)
          NAMEWORKER NOT NULL VARCHAR2(50 CHAR)
          SPECIALITY NOT NULL VARCHAR2(50 CHAR)
          YEARSOLD NOT NULL NUMBER(38)
          NIFCOMPANY NOT NULL VARCHAR2(9 CHAR)





          share|improve this answer






























            0














            I think the issue is that you are specifying constraint name during column definition. You cannot do that. You should specify constraints differently if you want to give them name.
            Try :



            CREATE TABLE Worker(
            nif VARCHAR2(9 CHAR) ,
            nameworker VARCHAR2(50 CHAR) ,
            specialty VARCHAR2(50 CHAR),
            CONSTRAINT CH_Speciality CHECK (speciality ='ENGINEERING' OR speciality= 'SUPPORT' OR speciality='DEVELOPMENT'),
            yearsold INTEGER,
            CONSTRAINT CH_Years CHECK (yearsold >= 1),
            CONSTRAINT NN_Years check(yearold is NOT NULL),
            nifCompany VARCHAR2(9 CHAR) ,
            CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif),
            CONSTRAINT PK_Nif PRIMARY KEY(nif),
            CONSTRAINT NN_NameWorker check(nameworker is NOT NULL),
            CONSTRAINT NN_Specialty check(specialty is NOT NULL),
            CONSTRAINT NN_NifCompany check(nifCompany is NOT NULL)
            );


            Let me know if you face further issues






            share|improve this answer























            • You have yearold instead of yearsold in NN_years, and the specialty typo from the original code. Other than that this works, but moving the not-null constraints into out-of-line check constraints means the data dictionary doesn't know the columns are not nullable, in all_tab_columns and when describing the table; which looks cosmetic but it can affect the optimizer. You can name not-null constraints in-line to avoid that.

              – Alex Poole
              Nov 13 '18 at 11:34






            • 1





              I can’t really see the point of naming NOT NULL constraints in the first place. It just seems to impose a burden on the schema designer for no benefit. Oracle doesn’t report the custom name on violation anyway, as it uses ORA-01400 Cannot insert null into (column spec) for that. (I rather wish there was something similar for foreign keys.)

              – William Robertson
              Nov 13 '18 at 14:12










            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',
            autoActivateHeartbeat: false,
            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%2f53278451%2ferror-creating-oracle-table-invalid-identifier%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









            1














            You have a couple of problems; the immediate cause of the error is this line:



            CONSTRAINT NN_Years NOT NULL,


            which based on the earlier naming you probably meant to include inline with the column definition:



            yearsold INTEGER CONSTRAINT NN_Years NOT NULL,
            CONSTRAINT CH_Years CHECK (yearsold >= 1),


            The second problem is that you've got inconsistent names, specialty in the column definition vs. speciality in the check constraint; so you need to fix the column and not-null constraint names:



            speciality VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,


            Fixing those things, and assuming you do have a Company table with a matching PK for the FK this specifies, gives you:



            CREATE TABLE Worker(
            nif VARCHAR2(9 CHAR) CONSTRAINT PK_Nif PRIMARY KEY,
            nameworker VARCHAR2(50 CHAR) CONSTRAINT NN_NameWorker NOT NULL,
            speciality VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,
            CONSTRAINT CH_Speciality CHECK (speciality = 'ENGINEERING'
            OR speciality = 'SUPPORT' OR speciality = 'DEVELOPMENT'),
            yearsold INTEGER CONSTRAINT NN_Years NOT NULL,
            CONSTRAINT CH_Years CHECK (yearsold >= 1),
            nifCompany VARCHAR2(9 CHAR) CONSTRAINT NN_NifCompany NOT NULL,
            CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif)
            );

            Table WORKER created.

            desc worker

            Name Null? Type
            ---------- -------- -----------------
            NIF NOT NULL VARCHAR2(9 CHAR)
            NAMEWORKER NOT NULL VARCHAR2(50 CHAR)
            SPECIALITY NOT NULL VARCHAR2(50 CHAR)
            YEARSOLD NOT NULL NUMBER(38)
            NIFCOMPANY NOT NULL VARCHAR2(9 CHAR)





            share|improve this answer



























              1














              You have a couple of problems; the immediate cause of the error is this line:



              CONSTRAINT NN_Years NOT NULL,


              which based on the earlier naming you probably meant to include inline with the column definition:



              yearsold INTEGER CONSTRAINT NN_Years NOT NULL,
              CONSTRAINT CH_Years CHECK (yearsold >= 1),


              The second problem is that you've got inconsistent names, specialty in the column definition vs. speciality in the check constraint; so you need to fix the column and not-null constraint names:



              speciality VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,


              Fixing those things, and assuming you do have a Company table with a matching PK for the FK this specifies, gives you:



              CREATE TABLE Worker(
              nif VARCHAR2(9 CHAR) CONSTRAINT PK_Nif PRIMARY KEY,
              nameworker VARCHAR2(50 CHAR) CONSTRAINT NN_NameWorker NOT NULL,
              speciality VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,
              CONSTRAINT CH_Speciality CHECK (speciality = 'ENGINEERING'
              OR speciality = 'SUPPORT' OR speciality = 'DEVELOPMENT'),
              yearsold INTEGER CONSTRAINT NN_Years NOT NULL,
              CONSTRAINT CH_Years CHECK (yearsold >= 1),
              nifCompany VARCHAR2(9 CHAR) CONSTRAINT NN_NifCompany NOT NULL,
              CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif)
              );

              Table WORKER created.

              desc worker

              Name Null? Type
              ---------- -------- -----------------
              NIF NOT NULL VARCHAR2(9 CHAR)
              NAMEWORKER NOT NULL VARCHAR2(50 CHAR)
              SPECIALITY NOT NULL VARCHAR2(50 CHAR)
              YEARSOLD NOT NULL NUMBER(38)
              NIFCOMPANY NOT NULL VARCHAR2(9 CHAR)





              share|improve this answer

























                1












                1








                1







                You have a couple of problems; the immediate cause of the error is this line:



                CONSTRAINT NN_Years NOT NULL,


                which based on the earlier naming you probably meant to include inline with the column definition:



                yearsold INTEGER CONSTRAINT NN_Years NOT NULL,
                CONSTRAINT CH_Years CHECK (yearsold >= 1),


                The second problem is that you've got inconsistent names, specialty in the column definition vs. speciality in the check constraint; so you need to fix the column and not-null constraint names:



                speciality VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,


                Fixing those things, and assuming you do have a Company table with a matching PK for the FK this specifies, gives you:



                CREATE TABLE Worker(
                nif VARCHAR2(9 CHAR) CONSTRAINT PK_Nif PRIMARY KEY,
                nameworker VARCHAR2(50 CHAR) CONSTRAINT NN_NameWorker NOT NULL,
                speciality VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,
                CONSTRAINT CH_Speciality CHECK (speciality = 'ENGINEERING'
                OR speciality = 'SUPPORT' OR speciality = 'DEVELOPMENT'),
                yearsold INTEGER CONSTRAINT NN_Years NOT NULL,
                CONSTRAINT CH_Years CHECK (yearsold >= 1),
                nifCompany VARCHAR2(9 CHAR) CONSTRAINT NN_NifCompany NOT NULL,
                CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif)
                );

                Table WORKER created.

                desc worker

                Name Null? Type
                ---------- -------- -----------------
                NIF NOT NULL VARCHAR2(9 CHAR)
                NAMEWORKER NOT NULL VARCHAR2(50 CHAR)
                SPECIALITY NOT NULL VARCHAR2(50 CHAR)
                YEARSOLD NOT NULL NUMBER(38)
                NIFCOMPANY NOT NULL VARCHAR2(9 CHAR)





                share|improve this answer













                You have a couple of problems; the immediate cause of the error is this line:



                CONSTRAINT NN_Years NOT NULL,


                which based on the earlier naming you probably meant to include inline with the column definition:



                yearsold INTEGER CONSTRAINT NN_Years NOT NULL,
                CONSTRAINT CH_Years CHECK (yearsold >= 1),


                The second problem is that you've got inconsistent names, specialty in the column definition vs. speciality in the check constraint; so you need to fix the column and not-null constraint names:



                speciality VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,


                Fixing those things, and assuming you do have a Company table with a matching PK for the FK this specifies, gives you:



                CREATE TABLE Worker(
                nif VARCHAR2(9 CHAR) CONSTRAINT PK_Nif PRIMARY KEY,
                nameworker VARCHAR2(50 CHAR) CONSTRAINT NN_NameWorker NOT NULL,
                speciality VARCHAR2(50 CHAR) CONSTRAINT NN_Specialty NOT NULL,
                CONSTRAINT CH_Speciality CHECK (speciality = 'ENGINEERING'
                OR speciality = 'SUPPORT' OR speciality = 'DEVELOPMENT'),
                yearsold INTEGER CONSTRAINT NN_Years NOT NULL,
                CONSTRAINT CH_Years CHECK (yearsold >= 1),
                nifCompany VARCHAR2(9 CHAR) CONSTRAINT NN_NifCompany NOT NULL,
                CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif)
                );

                Table WORKER created.

                desc worker

                Name Null? Type
                ---------- -------- -----------------
                NIF NOT NULL VARCHAR2(9 CHAR)
                NAMEWORKER NOT NULL VARCHAR2(50 CHAR)
                SPECIALITY NOT NULL VARCHAR2(50 CHAR)
                YEARSOLD NOT NULL NUMBER(38)
                NIFCOMPANY NOT NULL VARCHAR2(9 CHAR)






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 13 '18 at 11:26









                Alex PooleAlex Poole

                134k6108182




                134k6108182























                    0














                    I think the issue is that you are specifying constraint name during column definition. You cannot do that. You should specify constraints differently if you want to give them name.
                    Try :



                    CREATE TABLE Worker(
                    nif VARCHAR2(9 CHAR) ,
                    nameworker VARCHAR2(50 CHAR) ,
                    specialty VARCHAR2(50 CHAR),
                    CONSTRAINT CH_Speciality CHECK (speciality ='ENGINEERING' OR speciality= 'SUPPORT' OR speciality='DEVELOPMENT'),
                    yearsold INTEGER,
                    CONSTRAINT CH_Years CHECK (yearsold >= 1),
                    CONSTRAINT NN_Years check(yearold is NOT NULL),
                    nifCompany VARCHAR2(9 CHAR) ,
                    CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif),
                    CONSTRAINT PK_Nif PRIMARY KEY(nif),
                    CONSTRAINT NN_NameWorker check(nameworker is NOT NULL),
                    CONSTRAINT NN_Specialty check(specialty is NOT NULL),
                    CONSTRAINT NN_NifCompany check(nifCompany is NOT NULL)
                    );


                    Let me know if you face further issues






                    share|improve this answer























                    • You have yearold instead of yearsold in NN_years, and the specialty typo from the original code. Other than that this works, but moving the not-null constraints into out-of-line check constraints means the data dictionary doesn't know the columns are not nullable, in all_tab_columns and when describing the table; which looks cosmetic but it can affect the optimizer. You can name not-null constraints in-line to avoid that.

                      – Alex Poole
                      Nov 13 '18 at 11:34






                    • 1





                      I can’t really see the point of naming NOT NULL constraints in the first place. It just seems to impose a burden on the schema designer for no benefit. Oracle doesn’t report the custom name on violation anyway, as it uses ORA-01400 Cannot insert null into (column spec) for that. (I rather wish there was something similar for foreign keys.)

                      – William Robertson
                      Nov 13 '18 at 14:12















                    0














                    I think the issue is that you are specifying constraint name during column definition. You cannot do that. You should specify constraints differently if you want to give them name.
                    Try :



                    CREATE TABLE Worker(
                    nif VARCHAR2(9 CHAR) ,
                    nameworker VARCHAR2(50 CHAR) ,
                    specialty VARCHAR2(50 CHAR),
                    CONSTRAINT CH_Speciality CHECK (speciality ='ENGINEERING' OR speciality= 'SUPPORT' OR speciality='DEVELOPMENT'),
                    yearsold INTEGER,
                    CONSTRAINT CH_Years CHECK (yearsold >= 1),
                    CONSTRAINT NN_Years check(yearold is NOT NULL),
                    nifCompany VARCHAR2(9 CHAR) ,
                    CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif),
                    CONSTRAINT PK_Nif PRIMARY KEY(nif),
                    CONSTRAINT NN_NameWorker check(nameworker is NOT NULL),
                    CONSTRAINT NN_Specialty check(specialty is NOT NULL),
                    CONSTRAINT NN_NifCompany check(nifCompany is NOT NULL)
                    );


                    Let me know if you face further issues






                    share|improve this answer























                    • You have yearold instead of yearsold in NN_years, and the specialty typo from the original code. Other than that this works, but moving the not-null constraints into out-of-line check constraints means the data dictionary doesn't know the columns are not nullable, in all_tab_columns and when describing the table; which looks cosmetic but it can affect the optimizer. You can name not-null constraints in-line to avoid that.

                      – Alex Poole
                      Nov 13 '18 at 11:34






                    • 1





                      I can’t really see the point of naming NOT NULL constraints in the first place. It just seems to impose a burden on the schema designer for no benefit. Oracle doesn’t report the custom name on violation anyway, as it uses ORA-01400 Cannot insert null into (column spec) for that. (I rather wish there was something similar for foreign keys.)

                      – William Robertson
                      Nov 13 '18 at 14:12













                    0












                    0








                    0







                    I think the issue is that you are specifying constraint name during column definition. You cannot do that. You should specify constraints differently if you want to give them name.
                    Try :



                    CREATE TABLE Worker(
                    nif VARCHAR2(9 CHAR) ,
                    nameworker VARCHAR2(50 CHAR) ,
                    specialty VARCHAR2(50 CHAR),
                    CONSTRAINT CH_Speciality CHECK (speciality ='ENGINEERING' OR speciality= 'SUPPORT' OR speciality='DEVELOPMENT'),
                    yearsold INTEGER,
                    CONSTRAINT CH_Years CHECK (yearsold >= 1),
                    CONSTRAINT NN_Years check(yearold is NOT NULL),
                    nifCompany VARCHAR2(9 CHAR) ,
                    CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif),
                    CONSTRAINT PK_Nif PRIMARY KEY(nif),
                    CONSTRAINT NN_NameWorker check(nameworker is NOT NULL),
                    CONSTRAINT NN_Specialty check(specialty is NOT NULL),
                    CONSTRAINT NN_NifCompany check(nifCompany is NOT NULL)
                    );


                    Let me know if you face further issues






                    share|improve this answer













                    I think the issue is that you are specifying constraint name during column definition. You cannot do that. You should specify constraints differently if you want to give them name.
                    Try :



                    CREATE TABLE Worker(
                    nif VARCHAR2(9 CHAR) ,
                    nameworker VARCHAR2(50 CHAR) ,
                    specialty VARCHAR2(50 CHAR),
                    CONSTRAINT CH_Speciality CHECK (speciality ='ENGINEERING' OR speciality= 'SUPPORT' OR speciality='DEVELOPMENT'),
                    yearsold INTEGER,
                    CONSTRAINT CH_Years CHECK (yearsold >= 1),
                    CONSTRAINT NN_Years check(yearold is NOT NULL),
                    nifCompany VARCHAR2(9 CHAR) ,
                    CONSTRAINT FK_NifCompany FOREIGN KEY (nifCompany) REFERENCES Company(nif),
                    CONSTRAINT PK_Nif PRIMARY KEY(nif),
                    CONSTRAINT NN_NameWorker check(nameworker is NOT NULL),
                    CONSTRAINT NN_Specialty check(specialty is NOT NULL),
                    CONSTRAINT NN_NifCompany check(nifCompany is NOT NULL)
                    );


                    Let me know if you face further issues







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 13 '18 at 10:25









                    codeLovercodeLover

                    2,2551620




                    2,2551620












                    • You have yearold instead of yearsold in NN_years, and the specialty typo from the original code. Other than that this works, but moving the not-null constraints into out-of-line check constraints means the data dictionary doesn't know the columns are not nullable, in all_tab_columns and when describing the table; which looks cosmetic but it can affect the optimizer. You can name not-null constraints in-line to avoid that.

                      – Alex Poole
                      Nov 13 '18 at 11:34






                    • 1





                      I can’t really see the point of naming NOT NULL constraints in the first place. It just seems to impose a burden on the schema designer for no benefit. Oracle doesn’t report the custom name on violation anyway, as it uses ORA-01400 Cannot insert null into (column spec) for that. (I rather wish there was something similar for foreign keys.)

                      – William Robertson
                      Nov 13 '18 at 14:12

















                    • You have yearold instead of yearsold in NN_years, and the specialty typo from the original code. Other than that this works, but moving the not-null constraints into out-of-line check constraints means the data dictionary doesn't know the columns are not nullable, in all_tab_columns and when describing the table; which looks cosmetic but it can affect the optimizer. You can name not-null constraints in-line to avoid that.

                      – Alex Poole
                      Nov 13 '18 at 11:34






                    • 1





                      I can’t really see the point of naming NOT NULL constraints in the first place. It just seems to impose a burden on the schema designer for no benefit. Oracle doesn’t report the custom name on violation anyway, as it uses ORA-01400 Cannot insert null into (column spec) for that. (I rather wish there was something similar for foreign keys.)

                      – William Robertson
                      Nov 13 '18 at 14:12
















                    You have yearold instead of yearsold in NN_years, and the specialty typo from the original code. Other than that this works, but moving the not-null constraints into out-of-line check constraints means the data dictionary doesn't know the columns are not nullable, in all_tab_columns and when describing the table; which looks cosmetic but it can affect the optimizer. You can name not-null constraints in-line to avoid that.

                    – Alex Poole
                    Nov 13 '18 at 11:34





                    You have yearold instead of yearsold in NN_years, and the specialty typo from the original code. Other than that this works, but moving the not-null constraints into out-of-line check constraints means the data dictionary doesn't know the columns are not nullable, in all_tab_columns and when describing the table; which looks cosmetic but it can affect the optimizer. You can name not-null constraints in-line to avoid that.

                    – Alex Poole
                    Nov 13 '18 at 11:34




                    1




                    1





                    I can’t really see the point of naming NOT NULL constraints in the first place. It just seems to impose a burden on the schema designer for no benefit. Oracle doesn’t report the custom name on violation anyway, as it uses ORA-01400 Cannot insert null into (column spec) for that. (I rather wish there was something similar for foreign keys.)

                    – William Robertson
                    Nov 13 '18 at 14:12





                    I can’t really see the point of naming NOT NULL constraints in the first place. It just seems to impose a burden on the schema designer for no benefit. Oracle doesn’t report the custom name on violation anyway, as it uses ORA-01400 Cannot insert null into (column spec) for that. (I rather wish there was something similar for foreign keys.)

                    – William Robertson
                    Nov 13 '18 at 14:12

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278451%2ferror-creating-oracle-table-invalid-identifier%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

                    𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                    Edmonton

                    Crossroads (UK TV series)