Friday, August 11, 2017

SQL: How to tell if an existing index is unique?

A. Oracle

select INDEX_NAME, UNIQUENESS
from dba_indexes
where owner ='<owner>' and INDEX_NAME = '<index name>';

      Sample output:

INDEX_NAME                     UNIQUENES
------------------------------       ---------
EMPLOYEE_KEY_IDX      UNIQUE

B. Postgresql

SELECT relname AS INDEX_NAME, indisunique as UNIQUENESS
FROM pg_class, pg_index
WHERE pg_class.oid = pg_index.indexrelid AND relname !~ '^pg_' and relname = '<index name>';

        Sample output:

           index_name                             uniqueness
------------------------------------------+------------
 employee_license_idx                      f

---------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

No comments:

Post a Comment