The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.
Thanks for the question.
Asked: August 18, 2016 - 8:39 pm UTC
Last updated: August 19, 2016 - 4:26 am UTC
Version: 10
Viewed 1000+ times
SELECT AIC.INDEX_NAME AS IndexName, CASE ALC.CONSTRAINT_TYPE WHEN 'P' THEN 'T' ELSE 'F' END AS IsPrimary, CASE ALC.CONSTRAINT_TYPE WHEN 'U' THEN 'T' ELSE 'F' END AS IsUnique, AIC.COLUMN_NAME AS ColumnName FROM ALL_IND_COLUMNS AIC LEFT JOIN ALL_CONSTRAINTS ALC ON AIC.INDEX_NAME = ALC.CONSTRAINT_NAME AND AIC.TABLE_NAME = ALC.TABLE_NAME AND AIC.TABLE_OWNER = ALC.OWNER WHERE UPPER(AIC.TABLE_NAME) = UPPER('TEST')
SQL> create global temporary table ALL_OF_IT 2 on commit preserve rows as 3 SELECT AIC.TABLE_NAME, AIC.INDEX_NAME AS IndexName, 4 CASE ALC.CONSTRAINT_TYPE 5 WHEN 'P' THEN 'T' 6 ELSE 'F' 7 END AS IsPrimary, 8 CASE ALC.CONSTRAINT_TYPE 9 WHEN 'U' THEN 'T' 10 ELSE 'F' 11 END AS IsUnique, 12 AIC.COLUMN_NAME AS ColumnName 13 FROM ( select * from ALL_IND_COLUMNS where table_owner = 'MCDONAC' ) AIC 14 LEFT JOIN ( select * from ALL_CONSTRAINTS where owner = 'MCDONAC' ) ALC ON AIC.INDEX_NAME = ALC.CONSTRAINT_NAME 15 AND AIC.TABLE_NAME = ALC.TABLE_NAME 16 AND AIC.TABLE_OWNER = ALC.OWNER; Table created. Elapsed: 00:00:12.84
SQL> SQL> select * from ALL_OF_IT 2 where TABLE_NAME = UPPER('PARENT'); TABLE_NAME ------------------------------ INDEXNAME I -------------------------------------------------------------------------------------------------------------------------------- - I - COLUMNNAME ---------------------------------------------------------------------------------------------------------------------------------- PARENT SYS_C0020656 T F F1 Elapsed: 00:00:00.00
Share and learn SQL and PL/SQL; free access to the latest version of Oracle Database!
Classes, workouts and quizzes on Oracle Database technologies. Expertise through exercise!