Unique Column Constraint

PostgreSQL - related issues
Post Reply
1DMF
Posts: 19
Joined: Tue May 01, 2012 2:00 pm

Unique Column Constraint

Post by 1DMF » Tue Dec 03, 2013 7:05 pm

Hi,

I can't seem to work out how I set a Unique column constraint against the table column.

I can apply table wide indexes and contraints, how do I do a column constraint?

Thanks,
1DMF

1DMF
Posts: 19
Joined: Tue May 01, 2012 2:00 pm

Re: Unique Column Constraint

Post by 1DMF » Tue Dec 03, 2013 9:05 pm

I did some digging in the PostGreSQL docs and found this...
PostgreSQL automatically creates a unique index when a unique constraint or a primary key is defined for a table. The index covers the columns that make up the primary key or unique columns (a multicolumn index, if appropriate), and is the mechanism that enforces the constraint.
So as a unique column contraint is basically setting an alternate key, PostGreSQL handles this by creating unique indexes.

I guess dbschema decided instead of giving this as an option in the GUI to set a column unique, and then auto create the unique index, you leave us to implement the index to add a unique constraint!

Is a tick box for unique comming in any further development?

As the docs seem to have this notice?
Note: The preferred way to add a unique constraint to a table is ALTER TABLE ... ADD CONSTRAINT. The use of indexes to enforce unique constraints could be considered an implementation detail that should not be accessed directly. One should, however, be aware that there's no need to manually create indexes on unique columns; doing so would just duplicate the automatically-created index.
Thanks,
1DMF

donose.mihai
Posts: 470
Joined: Thu Apr 07, 2011 11:05 am

Re: Unique Column Constraint

Post by donose.mihai » Mon Dec 09, 2013 9:04 am

Hello,

I've added an issue ID: 0001733

Cheers,

Mihai

donose.mihai
Posts: 470
Joined: Thu Apr 07, 2011 11:05 am

Re: Unique Column Constraint

Post by donose.mihai » Wed Dec 11, 2013 7:50 am

Yes, we create unique indexes. It's right, you can declare the column unique, or create constraint which in fact is the same as creating an unique index. But we won't provide all this facilities, we better stay with one.

austingrd
Posts: 50
Joined: Sat Aug 24, 2013 3:03 pm

Re: Unique Column Constraint

Post by austingrd » Sat Dec 14, 2013 6:10 pm

1DMF wrote:Hi,

I can't seem to work out how I set a Unique column constraint against the table column.

I can apply table wide indexes and contraints, how do I do a column constraint?

Thanks,
1DMF
Hi 1DMF, I was assuming that this is already fixed for you. can you please share the steps here on what needs to be done?

angela456
Posts: 1
Joined: Mon Nov 28, 2016 10:25 am

Re: Unique Column Constraint

Post by angela456 » Mon Nov 28, 2016 10:26 am

it's right.

stewartouis
Posts: 1
Joined: Wed Mar 08, 2017 9:36 am

Re: Unique Column Constraint

Post by stewartouis » Wed Mar 08, 2017 9:39 am

I would like to thank you for the labors you must brand in writing this thing. I am hopeful the corresponding best work from you in the imminent as well. Thanks you for sharing.

http://www.dissertationplanet.co.uk/

Post Reply