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

0 In Auto_increment Field

forums forums SQLyog SQLyog: Bugs / Feature Requests 0 In Auto_increment Field

  • This topic is empty.
Viewing 1 reply thread
  • Author
    Posts
    • #9454
      trondvalen
      Member

      Is there a way to safely copy a table with the value 0 (zero) in an auto_increment field in SQLyog – Free MySQL GUI v4.1? It seems that such rows get the first key value available in the target table. And why can't you insert rows with 0 in auto_increment fields when you can update them to 0 later?

    • #20301
      peterlaursen
      Participant

      First: consider an upgrade of the SQLyog program! Latest version is 5.02. 5.1 beta will be out in less than a week. Registered users can upgrade for free.

      Next: your question.

      Because that is the way the server works with an INSERT statement! Even this SQL

      Code:
      insert into `test`.`t1` ( `id`, `t` ) values (  '0',  'rr' )

      executed against an empty table inserts '1' and not '0' into first row of the table

      However with an UPDATE staement like

      Code:
      update `test`.`t1` set  `id`='0',  `t`='rr' where `id`='1'

      current value is updated with a '0'. As long as the is only this row having his value. dublicates are not allowed with an autoincrement

      'autoincrement' means simply 'give me a unique number and I don't care which one'

      http://dev.mysql.com/doc/refman/5.0/en/exa…-increment.html . It is a MySQL issue – not a SQLyog issue. And like that in practically every database.

      I think that maybe you should consider redesigning your SCHEMA. It seems like you are using this column for more than one purpose.

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