Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个第三个表,它存储来自其他两个表的数据......
fk_first_table | fk_second_table 1 | 1 1 | 2 1 | 3 1 | 4 2 | 1 ...
我如何确保两个键永远不会重复...形成一个唯一的元组...就像一张真值表一样独特。
CREATE UNIQUE INDEX my_index ON tbl_name (fk1, fk2)
您需要创建一个唯一索引:
CREATE UNIQUE INDEX indexName ON thirdtable (fk_first_table, fk_second_table)