How to place a unique index on two fields in a table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2016 09:23 AM
I have two the fields field 1,field 2 in a table.
I want to keep unique index on those two fields..
How can we achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2016 09:32 AM
I guess, there is no provision for composite unique keys. However, you can write a "Data Policy" on the table. In that Data policy, write a script, which will check already records exists in that table with same values(Using GlideRecord)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2016 04:05 AM
Do you have the script for it.
Thanks,
Y Anji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2016 04:28 AM
Sorry,
I will take back my sentence that, there is no provision by default in SNOW. I missed the fact that, while creating index, we can select more than 1 column. Check the below screenshot. Select the table, In bottom, you can find "database indexes", click on new and add the columns into right slush buckets and click on "create index", this will create a composite unique key.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2016 04:43 AM
Than you ram reddy.
It is working.
After placing the index...I am getting the error"
java.sql.BatchUpdateException: Duplicate entry '6be744e14fd8a6409bec0f5d0210c73b-2016' for key 'contract'
Invalid insert"
I want to replace that error with beautiful message.How can we do that.
Thanks,
Y Anji