Skip to Content

Logical operators in check constraint

Feb 16 at 05:38 PM


avatar image

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

	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?


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers