Answer the question
In order to leave comments, you need to log in
Postgresql: One unique index for multiple tables?
Good afternoon.
There are several tables with different structure. Moreover, each of these tables has a hash field. I need the value of this field to be unique for all these tables. Something like one unique key for several tables.
Tell me, is there a way to do this at the RDBMS level, and not by manual checking from the code?
Answer the question
In order to leave comments, you need to log in
If someone is interested, I solved it like this: I created a sequence "hash_seq" and for these fields I registered the default value nextval ('hash_seq'). Uniqueness is guaranteed if you do not enter this value manually anywhere.
But this method only works if you need the uniqueness of values, but it is not necessary to specify the values yourself.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question