That is what the Primary Key will do as Mushroom suggested. If you try to Insert the record, it will throw an error -- no need to check, the database engine does it for you.
In MySQL, you would get the following message:
Code:
Error: 1022 SQLSTATE: 23000 (ER_DUP_KEY) Message: Can't write; duplicate key in table '%s'
All you need to do is build proper error traps and then resolve the errors accordingly. For proper MySQL error handling, refer to
http://dev.mysql.com/doc/mysql/en/Error-handling.html for more information.
This is also the preferred way of building database table structures. There will be cases that data could be loaded externally as from a text file. Letting the database engine do the checking for you and disallowing insertion of duplicate key values protects the integrity of the table.