60 | | WITH primarycols AS ( |
61 | | SELECT user_cons_columns.table_name, user_cons_columns.column_name, 1 AS PRIMARYCOL |
62 | | FROM user_cons_columns, user_constraints |
63 | | WHERE user_cons_columns.constraint_name = user_constraints.constraint_name AND |
64 | | user_constraints.constraint_type = 'P' AND |
65 | | user_cons_columns.table_name = %s), |
66 | | uniquecols AS ( |
67 | | SELECT user_ind_columns.table_name, user_ind_columns.column_name, 1 AS UNIQUECOL |
68 | | FROM user_indexes, user_ind_columns |
69 | | WHERE uniqueness = 'UNIQUE' AND |
70 | | user_indexes.index_name = user_ind_columns.index_name AND |
71 | | user_ind_columns.table_name = %s) |
72 | | SELECT allcols.column_name, primarycols.primarycol, uniquecols.UNIQUECOL |
73 | | FROM (SELECT column_name FROM primarycols UNION SELECT column_name FROM |
74 | | uniquecols) allcols, |
75 | | primarycols, uniquecols |
76 | | WHERE allcols.column_name = primarycols.column_name (+) AND |
77 | | allcols.column_name = uniquecols.column_name (+) |
| 60 | SELECT allcols.column_name, |
| 61 | primarycols.primarycol, |
| 62 | uniquecols.UNIQUECOL |
| 63 | FROM |
| 64 | (SELECT column_name |
| 65 | FROM |
| 66 | (SELECT user_cons_columns.table_name, |
| 67 | user_cons_columns.column_name , |
| 68 | 1 AS PRIMARYCOL |
| 69 | FROM user_cons_columns, |
| 70 | user_constraints |
| 71 | WHERE user_cons_columns.constraint_name = user_constraints.constraint_name |
| 72 | AND user_constraints.constraint_type = 'P' |
| 73 | AND user_cons_columns.table_name = %s |
| 74 | ) primarycols |
| 75 | |
| 76 | UNION |
| 77 | |
| 78 | SELECT column_name |
| 79 | FROM |
| 80 | (SELECT user_ind_columns.table_name, |
| 81 | user_ind_columns.column_name , |
| 82 | 1 AS UNIQUECOL |
| 83 | FROM user_indexes, |
| 84 | user_ind_columns |
| 85 | WHERE uniqueness = 'UNIQUE' |
| 86 | AND user_indexes.index_name = user_ind_columns.index_name |
| 87 | AND user_ind_columns.table_name = %s |
| 88 | )uniquecols |
| 89 | ) allcols , |
| 90 | (SELECT user_cons_columns.table_name, |
| 91 | user_cons_columns.column_name , |
| 92 | 1 AS PRIMARYCOL |
| 93 | FROM user_cons_columns, |
| 94 | user_constraints |
| 95 | WHERE user_cons_columns.constraint_name = user_constraints.constraint_name |
| 96 | AND user_constraints.constraint_type = 'P' |
| 97 | AND user_cons_columns.table_name = %s |
| 98 | ) primarycols , |
| 99 | (SELECT user_ind_columns.table_name, |
| 100 | user_ind_columns.column_name , |
| 101 | 1 AS UNIQUECOL |
| 102 | FROM user_indexes, |
| 103 | user_ind_columns |
| 104 | WHERE uniqueness = 'UNIQUE' |
| 105 | AND user_indexes.index_name = user_ind_columns.index_name |
| 106 | AND user_ind_columns.table_name = %s |
| 107 | ) uniquecols |
| 108 | WHERE allcols.column_name = primarycols.column_name (+) |
| 109 | AND allcols.column_name = uniquecols.column_name (+) |