Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2002
    Posts
    8

    Unanswered: varchar - length

    Hi All,

    I have created one table :

    CREATE TABLE `MYTAB` (`No` INT (3) UNSIGNED DEFAULT '0',
    `Name` VARCHAR (3)) TYPE = InnoDB;

    Now When I am trying to insert records into this table having "name" column's length greater than 3 It is truncating the string to three chars and inserting into the table.

    for example : insert into MYTAB values(1,'ABCDEF')

    is inserting a record into table MYTAB and now MYTAB contains

    ex :

    mysql> select * from MYTAB;
    +------+------+
    | No | Name |
    +------+------+
    | 1 | ABC |
    +------+------+
    1 row in set (0.00 sec)

    Instead this while entering the data into this table itself I expected mysql should throw exception saying that the length of name column is exceeding. Now I would like to force mysql to throw this exception. Please help me is there any way to force mysql to raise such exceptions.

    Regards,
    Sekhar

  2. #2
    Join Date
    Jan 2003
    Location
    Vietnam
    Posts
    188
    you might need to address your request to mysql developers
    qha_vn

  3. #3
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606
    Since MySQL still does not support transactions on all tables (MyISAM) they have to ignore most errors that would cause a rollback in other DBMS'. As such, you can insert character data into an int column, you can exceed the length of a CHAR (or INT for that matter) and it will not die. As far as I know this is intended functionality and is not slated to change.
    Thanks,

    Matt

Posting Permissions

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