Skip to Content

Logical operators in check constraint

I'm trying to create a table in the SQL console in the WDW. The SQL is:

CREATE TABLE VISIT (
	patientID	INT , 
	physicianID	INT 	NOT NULL, 
	visitDate	DATE, 
	admissionTime	INT,
	PRIMARY KEY (patientID, visitDate),
	CHECK (patientID <> physicianID),
    CHECK (admissionTime >= 0 AND admissionTime < 24*60)
);

The statement works until I add the last CHECK. When I do I get this error:

11:29:28 AM (SQL Editor) Could not execute 'CREATE TABLE VISIT ( patientID	INT , visitDate	DATE, visitTime	INT, reason	VARCHAR(40), ...'Error: (dberror) 288 - cannot use duplicate table name: VISIT: line 12 col 13 (at pos 1

line 12 refers to the CREATE TABLE line. I've tried removing the other check constraint but I get the same error. It seems to be the CHECK (admissionTime.. constraint that causes the problem.

Any Suggestions?

Ross

SQL
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers