Let's say I have a 3rd table that stores data from two other tables...
fk_first_table | fk_second_table
1 | 1
1 | 2
1 | 3
1 | 4
2 | 1
...
How can I assure that both keys never repeat... Forming a unique tuple... Kind of unique together like a table of truth.
CREATE UNIQUE INDEX my_index ON tbl_name (fk1, fk2)
您需要创建一个唯一索引:
CREATE UNIQUE INDEX indexName ON thirdtable (fk_first_table, fk_second_table)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.