Skip to main content
Inspiring
July 7, 2008
Question

do i always have to have a primary key in a mysql table?

  • July 7, 2008
  • 1 reply
  • 252 views
do I always have to have a primary key in a mysql table? what is best practise? thanks
    This topic has been closed for replies.

    1 reply

    July 7, 2008
    Technically no.

    However, you should always pick one for two reasons.
    1. You need something to uniquely identify a row so you can do an update or delete and only affect that row.
    2. A primary key is also an index and without indexes, your database will be much sloooooower.