I don't see implementation of "CHECK" CONSTRAINTS in the TODO list (e.g. 

  CONSTRAINT val_ck check (val >= 0 and val <=5)

Is this planned? 

I do see FOREIGN KEY constraints on the 4.0 list, so there is a way to do
this kind of checking once this is implemented:

* Create an associated "range-check" table with a primary key column, and
add rows for the values you want to allow in your table column.
* Put a foreign key constraint on your column to point at that table.

This will at least ensure that you get a constraint violation if you attempt
to insert something illegal.

This works only for small ranges or other enumeration types (integer or
string). E.g.

 create table check_phase_number (phase integer);
 insert into check_phase_number values (1),(2),(3),(4),(5);

 create table check_state_abbrev (state char(2));
 insert into check_state_abbrev values ('AK'),('AL'),('CA'), ...
('VT'),('WA');

 create table my_state_migration (
   phase integer constraint phase_fk foreign key references
check_phase_number(phase),
   state char(2) constraint state_fk foreign key references
check_state_abbrev(state),
   ...
 );


-----Original Message-----
From: Cal Evans [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 20, 2001 8:27 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Second Request - Limit Filed Input


you can use either an ENUM or a SET. Other than that, no.

Cal
http://www.calevans.com


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 20, 2001 10:05 AM
To: [EMAIL PROTECTED]
Subject: Second Request - Limit Filed Input


Is there a way in MySQL to limit the values that a (numeric) field can hold.
For example if I want a given field to only have the values 1 - 10 can I do
this and can it be done in the definition of the field when the table is
created?

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