0

I am trying to create a table and an index on it in Oracle SQL developer, but I keep getting the error:

Error report - SQL Error: ORA-00942: table or view does not exist 00942. 00000 - "table or view does not exist" *Cause:
*Action:

My statements:

CREATE TABLE TAB_ATTRIBUTES_OF_RELATIONSHIP
(
REL_NAME                VARCHAR(15) not null,
ATTR_NAME             VARCHAR(15) not null, 
ATTREL_DATATYPE  VARCHAR(15) not null, 
ATTREL_DOMAIN     VARCHAR(20),

constraint PK_ATTRIBUTES_OF_RELATIONSHIP primary key (REL_Name, ATTR_NAME),
constraint FK_ATTRIBUTES_OF_RELATIONSHIP foreign key (REL_NAME)
            references RELATIONSHIPS (REL_NAME)
constraint FK_ATTRIBUTES_OF_RELATIONSHIP foreign key (ATTR_NAME)
            references ATTRIBUTES (ATTR_NAME),
);

/* Index: IDX_ATTRIBUTES_OF_RELATIONSHIP    */

Create index IDX_ATTRIBUTES_OF_RELATIONSHIP_FK on Tab_ATTRIBUTES_OF_RELATIONSHIP

(
ATTR_NAME ASC
);
2
  • 4
    Can you access tables RELATIONSHIPS and ATTRIBUTES from the same SQL developer session? Commented Mar 31, 2016 at 0:21
  • Simplify the code to narrow down the problem. I assume only one of the statements is throwing an error, so remove the unnecessary statement. Then start removing columns, constraints, etc., until the statement is as small as possible and still throws an error. Also, the error message should normally display or highlight the relevant line and column number, that can also help you focus on the real problem. Commented Mar 31, 2016 at 3:37

1 Answer 1

0

The problem seems to be with the CREATE TABLE statement. You should pay attention where you place the commas, and maybe try to execute the script step by step

Here's a corrected version of your table creation statement

CREATE TABLE TAB_ATTRIBUTES_OF_RELATIONSHIP
(
REL_NAME                VARCHAR(15) not null,
ATTR_NAME             VARCHAR(15) not null, 
ATTREL_DATATYPE  VARCHAR(15) not null, 
ATTREL_DOMAIN     VARCHAR(20),
constraint PK_ATTRIBUTES_OF_RELATIONSHIP primary key (REL_Name, ATTR_NAME),
constraint FK_ATTRIBUTES_OF_RELATIONSHIP foreign key (REL_NAME)
            references RELATIONSHIPS (REL_NAME),
constraint FK_ATTRIBUTES_OF_RELATIONSHIP foreign key (ATTR_NAME)
            references ATTRIBUTES (ATTR_NAME)
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.