Written by

Deloitte
Question Michael Wood · Jun 14, 2024

Create a unique constraint on an existing table

I have a table that is already created and contains data.  I need to create a unique constraint that is a combination of two fields. Is there a way to do this in a SQL statement?  Also, I would lke to know how to add it in the table class.

Product version: IRIS 2021.1

Comments

Chris Stewart · Jun 14, 2024

The following SQL should do it

CREATE UNIQUE INDEX ON TABLE <table> (field1, field2)

You will then want to stop all operations against the data and build the index

0