How to make a case-insensitive unique column in SQLite

后端 未结 2 1406
情书的邮戳
情书的邮戳 2021-01-13 08:37

I haven\'t been able to find the answer to this. I\'m trying to create a table with a unique email address column. And when I do

CREATE TABLE users (
  email         


        
2条回答
  •  情歌与酒
    2021-01-13 09:10

    COLLATE NOCASE is your friend:

    CREATE TABLE users (
      email TEXT PRIMARY KEY,
      password TEXT NOT NULL CHECK(password<>''),
      UNIQUE (email COLLATE NOCASE)
    )
    

提交回复
热议问题