2uzhan.com
Advertisement
Now Place:2uzhan.com » Please Help, Problem with constraints

Please Help, Problem with constraints

MySQL @ February 25, 2005   Views:0

Ok, Hi, I was wondering if someone would be kind enough to help me out, i am trying to make a database for a university project, and i have created the following table, this is just a small part of the database, it creates ok, no errors, but the NOT NULLS and CHECK do not seem to work as i can enter data outside of the check parameters and enter nothing for the nulls.

Application being used: MySQL Server 4.1 (Windows edition)

CREATE TABLE staff(
staff_no MEDIUMINT(5) NOT NULL CHECK (value BETWEEN 10000 AND 99999),
fName VARCHAR(15) NOT NULL,
sName VARCHAR(15) NOT NULL,
system_lv TINYINT(1) NOT NULL CHECK (VALUE IN ('1','2','3')),
sex CHAR(1) NOT NULL DEFAULT 'M' CHECK (VALUE IN ('M','F')),
dob DATE,
site_no SMALLINT(3) NOT NULL,
PRIMARY KEY (staff_no));

Does anyone know why the NOT NULL / CHECK are not working, any help would be really useful, as i am unsure if there is something wrong with the code or the way inwhich i have set up MySQL.

Thanks for your time..

--------------Solutions-------------

rtfm:
http://dev.mysql.com/doc/mysql/en/create-table.html

http://animalliberation.tk http://veganismus.ch
http://maqi.de http://tierrechtskochbuch.de So i can't use the check syntax, like i have it in the code atm...? Cos i can't c it in the list...

I am a complete noobie at this... sorry... Christopher Hammond wrote:
> So i can't use the check syntax, like i have it in
> the code atm...? Cos i can't c it in the list...

you can leave it in the code but its ignored.

http://animalliberation.tk http://veganismus.ch
http://maqi.de http://tierrechtskochbuch.de why dont you use ENUM()?

http://animalliberation.tk http://veganismus.ch
http://maqi.de http://tierrechtskochbuch.de I will read up on ENUM()... :-D

Tags:
© 2018 2uzhan.com Contact