Create Unqiue case-insensitive constraint on two varchar fields

泄露秘密 提交于 2019-11-29 04:09:05

Assuming your table is called person, and the first and last name columns are called first_name and last_name, add this unique constraint:

ALTER TABLE person ADD CONSTRAINT person_name_unique
    UNIQUE(LOWER(first_name),LOWER(last_name));

Let me know if I understood your question correctly and made the correct assumptions about your table layout.

I've managed to get it working by doing:

CREATE UNIQUE INDEX person_name_upper ON person(
    UPPER(first_name), UPPER(last_name));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!