Wednesday, January 14, 2009

Mandate only pre define values to columns

CREATE TABLE `temp1` (
`col1` set('Select','Update') character set utf8 NOT NULL default '',
`col2` int) ;

The `col1` in the table will accept only two values i.e. 'select' and 'update'.

If you try to insert any other value part form this it throws a error
ERROR 1265 (01000): Data truncated for column 'col1' at row 1

No comments:

Post a Comment