Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (20.3k points)

I have the following table:

 tickername | tickerbbname  | tickertype


 USDZAR     | USDZAR Curncy | C

 EURCZK     | EURCZK Curncy | C

 EURPLN     | EURPLN Curncy | C

 USDBRL     | USDBRL Curncy | C

 USDTRY     | USDTRY Curncy | C

 EURHUF     | EURHUF Curncy | C

 USDRUB     | USDRUB Curncy | C

I don't want there to ever be more than one column for any given tickername/tickerbbname pair. I've already created the table and have lots of data in it (which I have already ensured meets the unique criteria). As it gets larger, though, room for error creeps in.

Is there any way to add a UNIQUE constraint at this point?

1 Answer

0 votes
by (40.4k points)

According to psql's inline:


Also,  it's mentioned in the postgres docs(an excellent resource, plus easy to read, too) like this:

ALTER TABLE tablename ADD CONSTRAINT constraintname UNIQUE (columns);

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories