H
H
HaruAtari2015-08-18 20:06:22
PostgreSQL
HaruAtari, 2015-08-18 20:06:22

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

2 answer(s)
H
HaruAtari, 2015-08-19
@HaruAtari

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.

S
sim3x, 2015-08-18
@sim3x

there were no built-in mechanisms in 2011
www.postgresql.org/message-id/20110620160307.683ab...
this can only happen if 3NF is not observed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question