I'm creating a table like this,
CREATE TABLE ARTIST (
ArtistID Int NOT NULL IDENTITY(1,1),
LastName Char(25) NOT NULL,
FirstName Char(25) NOT NULL,
Nationality Char(30) NULL,
DateOfBirth Numeric(4) NULL,
DateDeceased Numeric(4) NULL,
CONSTRAINT ArtistPK PRIMARY KEY(ArtistID),
CONSTRAINT ArtistAK1 UNIQUE(LastName, FirstName),
CONSTRAINT BirthValuesCheck CHECK (DateOfBirth < DateDeceased),
CONSTRAINT ValidBirthYear CHECK
(DateOfBirth LIKE '[1-2][0-9][0-9][0-9]'),
CONSTRAINT ValidDeathYear CHECK
(DateDeceased LIKE '[1-2][0-9][0-9][0-9]')
);
and I get this error :
Error report - SQL Error: ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis"
Any idea why?
UNIQUEconstraint on first & last name? Is it not possible to have multiple artists with the same name? Also, why not use aDATEdatetype for Date of Birth/Death? - MT0char(25)andchar(30)data types are almost certainly a poor choice. names and nationalities are variable length strings, usevarchar2instead. YourDateOfBirthandDateDeceasedshould almost certainly be adaterather than just storing a numeric year. If you want to put a check constraint on a numeric field, make a numeric comparison (i.e.YearOfBirth BETWEEN 1000 and 2999) - Justin Cave