Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    2

    Unanswered: rookie question on "check" command

    does anybody know how to set a max limit to the values to be inserted in a column? I tried with

    create table test (col1 varchar(10), col2 double check (col2 < 1));

    but it doesn't works infact it accepts any value.
    Thank you all.

  2. #2
    Join Date
    Jan 2004
    Posts
    2
    this seems to be a working solution:

    mysql> update test set col2=col2+0.1 where col1=1 and abs(col2)<1;

    when the value of col2 reaches 1 it stops being augmented

    mysql> update test set col2=col2+0.1 where col1=1 and abs(col2)<1;
    Query OK, 0 rows affected (0.00 sec)
    Rows matched: 0 Changed: 0 Warnings: 0

    mysql> select * from test;
    +----+--------+
    | col1| col2 |
    +----+--------+
    | 1 | 1 |
    +----+--------+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •