You can't lock a table directly, as we don't offer a way to lock a table. What is the exact use case here, for which you want to prevent duplicates but don't want to use the construct which is created for that: unique constraints?
Besides, table locks won't help unless you do follow this procedure:
- lock table
- fetch the row with the data you want to insert
- if there's a row, fail
- if not, insert
- release lock
WHich is exactly the same as when you use a unique constraint:
- insert row
- if there's already a row present the unique constraint fails, so the query fails.
In both situations the query fails and you have to report this to the user so he can alter the data to insert, as that's always needed.