Error creating Oracle table invalid identifier
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
add a comment |
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
add a comment |
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
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
oracle identifier
edited Nov 13 '18 at 10:07
mx0
2,78482633
2,78482633
asked Nov 13 '18 at 10:03
llinasencllinasenc
61
61
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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)
add a comment |
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
You haveyearold
instead ofyearsold
inNN_years
, and thespecialty
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, inall_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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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)
add a comment |
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)
add a comment |
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)
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)
answered Nov 13 '18 at 11:26
Alex PooleAlex Poole
134k6108182
134k6108182
add a comment |
add a comment |
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
You haveyearold
instead ofyearsold
inNN_years
, and thespecialty
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, inall_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
add a comment |
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
You haveyearold
instead ofyearsold
inNN_years
, and thespecialty
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, inall_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
add a comment |
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
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
answered Nov 13 '18 at 10:25
codeLovercodeLover
2,2551620
2,2551620
You haveyearold
instead ofyearsold
inNN_years
, and thespecialty
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, inall_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
add a comment |
You haveyearold
instead ofyearsold
inNN_years
, and thespecialty
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, inall_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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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