Unsupported Screen Size: The viewport size is too small for the theme to render properly.

How To Set Default Value For Bit Column?

forums forums SQLyog Using SQLyog How To Set Default Value For Bit Column?

  • This topic is empty.
Viewing 1 reply thread
  • Author
    Posts
    • #10012
      ziggy
      Member

      When I try to set the default value for a bit column to 0 or 1, I get Error #1067: Invalid default value for “NewUser”.

    • #22905
      peterlaursen
      Participant

      SQLyog does not yet support BIT types as of MySQL 5.

      Before version 5 MySQL stored BITS internally as a TINYINT – from version 5 it uses a binary storage format. That means that the correct SQL is for instance:

      Code:
      alter table `test2`.`tablename1` change `morebits` `morebits` bit (6) DEFAULT false NULL

      Note that a BIT is not a single binary value, but rather an array of such values. In this case an array of 6 of them. Refer to http://dev.mysql.com/doc/refman/5.0/en/num…e-overview.html.

      If you true to use SQLyog GUI to set the default as FALSE, SQLyog will quote it as a string and it will not be accepted by the server. You will need to execute it from SQL pane. And still SQLyog cannot display the values and you cannot enter values from SQLyog either.

      A single binary value is in SQL denoted as a BOOL type. MySQL still uses the TINYINT storage for this and you can work with it from SQLyog and use defaults '0' and '1' (without quotes).

Viewing 1 reply thread
  • You must be logged in to reply to this topic.