Jerome
Jerome

Reputation: 25

Oracle: invalid relational operator when creating a table with check constraint

im trying to create a table using oracle and i keep getting the same error again and again

ERROR at line 4: ORA-00920: invalid relational operator

Here is my piece of code:

    CREATE TABLE Joueur(
    pseudo VARCHAR(50) PRIMARY KEY,
    nome VARCHAR(255) REFERENCES Equipe(nome),
    nomj VARCHAR(50) CHECK (UPPER(SUBSTR(nomj, 1, 1))),
    dateNaissance DATE CHECK (to_char(dateNaissance,"YYYY/MM/DD") > '1984/01/08'), 
);

Thanks for your time

Upvotes: 1

Views: 1140

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269443

The fourth line has no comparison:

nomj VARCHAR(50) CHECK (UPPER(SUBSTR(nomj, 1, 1))),
-------------------------------------------------^

What do you want to check?

Also, I would write the last one as

dateNaissance DATE CHECK (dateNaissance > date '1984-01-08')

Converting to a string doesn't cause an error but it is entirely unnecessary.

And the final comma is also an error.

EDIT:

For the first comparison:

nomj VARCHAR(50) CHECK (SUBSTR(nomj, 1, 1) BETWEEN 'A' AND 'Z'),

Oracle comparisons are usually case sensitive.

Upvotes: 1

Related Questions