How can we prevent duplicate records in a MySQL table?

We can use these options to prevent duplicate records in MySQL table:

  • Primary Key: We can define a Primary key in a table. While entering data if there is already a record present with same Primary key, then duplicate record will be rejected.
  • Unique Index: We can also create a Unique Index on a column in a table. While inserting new data, if we use duplicate data then Unique index will throw error.
Read the full book at www.amazon.com
Posted in MySQL, MySQL Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *

*