how to use composite Unique using trigger I have one column user_id and service_id i want to restrict duplicate records in user_id according to service_id means ie for service_id=1 all records should be unique in user_id all by trigger
1 Answer
You don't need a trigger for this. A Unique constraint on multiple columns would do it.
ALTER TABLE tab ADD UNIQUE (service_id, user_id);
Docs at: http://www.postgresql.org/docs/current/static/ddl-constraints.html
2 Comments
Manish chand
I know this but i have to us it in trigger
Manish chand
I want unique for only for one service constraint on multiple columns will restrict all services