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.
假设我有一条 id=1、b=20 和 c=30 的记录。id 是我的主键。只有当没有 b=20 和 c=30 的记录时,我才想在数据库中插入一条新记录。到目前为止,我已经为 id 设置了一个主键,但是 b & c 呢?我该怎么做那个查询?谢谢你。
您可以使用在 B 和 C 上创建唯一键。
ALTER TABLE MyTable ADD UNIQUE MyIndex(b,c);