Search code examples
oracle12c

index with where condition - Oracle


I would like to have an equivalent Oracle query for the below SQL Query

SQL QUERY:

CREATE UNIQUE NONCLUSTERED INDEX ValidSub_Category ON ValidSub (Category ASC) WHERE (category IS NOT NULL)

purpose: This index is created to make sure that the column has more than 1 NULL records but does not have duplicate strings.

Thanks in advance


Solution

  • I found it

    CREATE UNIQUE INDEX VALIDSUB_CATEGORY ON VALIDSUB (Case WHEN Category IS NOT NULL THEN CATEGORY END);