pwaring,
@pwaring@fosstodon.org avatar

TIL: If you try to manually INSERT a row into a MySQL table and set an AUTO_INCREMENT column to 0, MySQL ignores the provided value and assumes you want the next increment amount.

Found this whilst migrating a legacy database to a new structure, where the legacy database had foreign keys (not actually defined as constraints) with 0 values.

You can control this with NO_AUTO_VALUE_ON_ZERO in sql_mode (it's on by default I think).

#MySQL #databases

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • kavyap
  • ngwrru68w68
  • Durango
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • thenastyranch
  • Youngstown
  • khanakhh
  • slotface
  • everett
  • vwfavf
  • rosin
  • osvaldo12
  • megavids
  • GTA5RPClips
  • ethstaker
  • tacticalgear
  • InstantRegret
  • cisconetworking
  • cubers
  • tester
  • anitta
  • modclub
  • Leos
  • normalnudes
  • provamag3
  • JUstTest
  • All magazines