0

Trying to add UNIQUE attribute to existing column, getting syntax error

smartbrain=# ALTER TABLE users ALTER COLUMN email VARCHAR(100) UNIQUE NOT NULL;

ERROR:  syntax error at or near "VARCHAR"
LINE 1: ALTER TABLE users ALTER COLUMN email VARCHAR(100) UNIQUE NOT...
0

1 Answer 1

0

If "users" already has column "email", and the data type is already "varchar(100)", then try this:

ALTER TABLE users
  ADD  UNIQUE (email);

ALTER TABLE users
  ALTER COLUMN email set NOT NULL;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.