Two things:

1)  Read the manual to see the correct syntax for the CREATE TABLE.

2)  Constraints don't actually do anything in MySQL.  Again, read the
manual.

-Tilghman

-- 
"There cannot be a crisis today.  My schedule is already full."
     --Henry Kissinger

> -----Original Message-----
> From: SF [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 07, 2001 15:26
> 
> When I try to run the following command:
> 
> CREATE TABLE Salespersons
>  (empid INTEGER NOT NULL PRIMARY KEY,
>  ename CHAR(15) NOT NULL,
>  rank INTEGER NOT NULL DEFAULT 1 CHECK (rank IN (1,2,3)),
>  salary DECIMAL(7, 2) NOT NULL DEFAULT 1000.00 CHECK (salary 
> >=1000.00));
> 
> gives me the following error:
> 
> You have an error in your SQL syntax near 'CHECK (rank IN (1,2,3)),
> salary...'
> 
> I've looked through the MySQL manual and cannot find anything 
> that would
> help explain why I cannot run any of the CHECK constraints - 
> it does not
> work when I delete that first CHECK constraint, because the 
> second one is
> there - if I delete both CHECK constraints, the command to 
> create the table
> works.  I've tried it with creating different tables and it 
> still doesn't
> work - and I can't figure out why.
> 
> I'm pretty new to SQL.  Other than using it in a number of 
> databases I've
> designed using MS Access, I don't have much experience.  I'm 
> working (if any
> other newbies might have noticed) straight from a book by Wrox called
> "Instant SQL Programming" to try and cut my teeth on this...

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to