>>Two things:
>>
>>1)  Read the manual to see the correct syntax for the CREATE TABLE.

I did, and that's where I don't understand why this is happening.  The
furthest I was able to get in the manual and/or any of the archives from
MySQL is:

(straight out of the manual)
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
[table_options] [select_statement]

create_definition:
  col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
            [PRIMARY KEY] [reference_definition]
  or    PRIMARY KEY (index_col_name,...)
  or    KEY [index_name] (index_col_name,...)
  or    INDEX [index_name] (index_col_name,...)
  or    UNIQUE [INDEX] [index_name] (index_col_name,...)
  or    FULLTEXT [INDEX] [index_name] (index_col_name,...)
  or    [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...)
            [reference_definition]
  or    CHECK (expr)

        ^^^^^^^^^^^^
        ||||||||||||

The comment that CHECK (expr) is supposed to be written as such, is
something that I either don't understand - and if so, what is wrong with it
in the string I am using (line 4: "CHECK (rank IN (1,2,3))")? - or an error
I don't understand is causing this - that's why I'm asking.

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

I understand and I am - over and over.

More info: the actual error number is: 1064


> -----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