0

I am trying to create a table. I am unable to compile it successfully. Could someone please point me in the right direction

Here is my code:

 CREATE TABLE TESTING_TODAY
 (
 EMP_NUM NUMBER(5, 0) NOT NULL, 
 RTG_CODE CHAR(5 BYTE) NOT NULL,
 EARNED_DATE DATE NOT NULL
 CONSTRAINT PK_TESTING_TODAY PRIMARY KEY CLUSTERED 
 (
   [EMP_NUM] ASC,
   [RTG_CODE] ASC
 )
 );
 COMMIT;
3
  • 3
    If you're "unable to compile it", presumably you're getting some sort of error. It would be awfully helpful to specify that error. You haven't told us what database you're connected to. You've tagged this for SQL Developer which would imply an Oracle database but the SQL you've posted definitely isn't Oracle DDL. Commented May 5, 2014 at 22:37
  • @Justin CaveI am using Oracle SQL Developer as I tagged it. The error is "Error at Command Line : 6 Column : 12 Error report - SQL Error: ORA-02250: missing or invalid constraint name 02250. 00000 - "missing or invalid constraint name" *Cause: The constraint name is missing or invalid. *Action: Specify a valid identifier name for the constraint name." Commented May 5, 2014 at 22:39
  • In future, read the error message. (i.e. learn to fish, you'll feed yourself for a lifetime) Commented May 7, 2014 at 3:21

1 Answer 1

3

CLUSTERED is invalid in Oracle and [,] are invalid in SQL identifiers:

CREATE TABLE TESTING_TODAY
(
   EMP_NUM NUMBER(5, 0) NOT NULL, 
   RTG_CODE CHAR(5 BYTE) NOT NULL,
   EARNED_DATE DATE NOT NULL,
   CONSTRAINT PK_TESTING_TODAY PRIMARY KEY (EMP_NUM,RTG_CODE)
);
COMMIT;
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I was pointed in the wrong direction earlier by a friend. Thanks for the clarification and good articles.

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.