Prevent Insertion of Duplicate Information in SQL

Is there a quick way to prevent duplicate data from being inserted into a table? I mean, the key will always be different, but the rest of the record can be repeated, and thus there would be two different keys identifying the same data.

I could search the whole table, but I am afraid that the performance lost in doing so.

Note. I'm just starting to learn SQL, please bear with me if this is a dumb question for you.

+3
source share
4 answers

You want a UNIQUE constraint in a table.

+10
source

, UNIQUE , .

, , , .

ex: ,

+2

. .

0

. " " .

We also had a problem with company registration data, such as addresses, phone numbers, etc. You just need to narrow down all possible data options and then perform simple checks. There is probably no (good) way to make these checks the best result for any data.

-1
source

Source: https://habr.com/ru/post/1705280/


All Articles