Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL and CHECK

Status
Not open for further replies.

wolfmah

Programmer
Oct 24, 2001
17
CA
Is it possible in MySQL to put a CHECK in your CREATE TABLE sentence? I have try this below but it doesn't work at all.

CREATE TABLE test(
id TINYINT UNSIGNED NOT NULL ,
PRIMARY KEY ( id ) ,
UNIQUE UC_id( id ) ,
CHECK (
id > 33
)
);
 
Check constraints in Mysql are bogus. They allow the syntax but they don't enforce the constraint. No alternative but doing the checking yourself.

A primary key constraint implies uniqueness, so having both is redundant.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top