SQL Unique Record not column?

前端 未结 4 1749
[愿得一人]
[愿得一人] 2021-01-07 02:14

Is there a way to insert into an SQL database where the whole record is unique? I know you can make primary keys and unique columns, but that is not what I want.

Wha

4条回答
  •  半阙折子戏
    2021-01-07 02:48

    You know how to make a unique index on a column.

    Just make that on all the columns that should, together, be unique:

    create unique index foo 
    on tablename(columnone, columntwo, columnthree);
    

    Note that the need to do this may be an indication that your table is not sufficiently normalized.

提交回复
热议问题