Search code examples
sqlsap-iq

Was a table created with iq unique option?


I have some tables on sybase-iq data base, created for example:

create  table tab
(   
   id   int  not null IQ Unique (10)
)  

How can I check if table tab was created with iq unique option?


Solution

  • We can do that using procedure sp_column. It returns informations about every column in the table. In a est_cardinality column is the value from IQ Unique. For example:

    sp_iqcolumn tab
    

    returns

    table_name  table_owner column_name domain_name width   scale   nulls   default cardinality est_cardinality location    isPartitioned   remarks check
    tab         DBA         id          integer     4       0       N               0           10               Main       N
    

    Here is link to documentation.