DQL subquery - is already defined - doctrine-query

I'm trying to reuse the definition name "comments" - table Comments (AppBundle:Comments entity) in the 5th DQL subquery, but I get the error: "Error: 'comments' is already defined."
Here is the DQL query:
SELECT employer.name AS employer_name, employer.position AS employer_position, employer.id AS employer_id,
(SELECT company.company_name FROM Application\Sonata\UserBundle\Entity\User company WHERE company.id = employer.company) AS company_name,
(SELECT city.name FROM AppBundle:City city WHERE city.id = employer.city) AS city_name,
(SELECT MAX(comments.id) FROM AppBundle:Comments comments WHERE comments.employer = employer_id) AS comment_id,
(SELECT commenttype.name FROM AppBundle:CommentTypes commenttype WHERE commenttype.id = comment_id) AS comment_name,
(SELECT COUNT(comments.id) FROM AppBundle:Comments comments WHERE comments.employer = employer_id) AS comment_count
FROM AppBundle:Employer employer
How can I reuse the definition without redefining it?
I tried also with this:
SELECT employer.name AS employer_name, employer.position AS employer_position, employer.id AS employer_id,
(SELECT company.company_name FROM Application\Sonata\UserBundle\Entity\User company WHERE company.id = employer.company) AS company_name,
(SELECT city.name FROM AppBundle:City city WHERE city.id = employer.city) AS city_name,
(SELECT MAX(comments.id) FROM AppBundle:Comments comments WHERE comments.employer = employer_id) AS comment_id,
(SELECT commenttype.name FROM AppBundle:CommentTypes commenttype WHERE commenttype.id = comment_id) AS comment_name,
(SELECT COUNT(comments.id) FROM comments WHERE comments.employer = employer_id) AS comment_count
FROM AppBundle:Employer employer
, but now I get "Class 'comments' is not defined." error.

Seems a duplicate alias in the first query.
Try this:
SELECT employer.name AS employer_name, employer.position AS employer_position, employer.id AS employer_id,
(SELECT company.company_name FROM Application\Sonata\UserBundle\Entity\User company WHERE company.id = employer.company) AS company_name,
(SELECT city.name FROM AppBundle:City city WHERE city.id = employer.city) AS city_name,
(SELECT MAX(comments.id) FROM AppBundle:Comments comments WHERE comments.employer = employer_id) AS comment_id,
(SELECT commenttype.name FROM AppBundle:CommentTypes commenttype WHERE commenttype.id = comment_id) AS comment_name,
(SELECT COUNT(aComments.id) FROM AppBundle:Comments aComments WHERE aComments.employer = employer_id) AS comment_count
FROM AppBundle:Employer employer
Hope this help

Related

Report Job difference in HR schema

I'm new to Oracle and try to practice with HR schema. For example I want to report of those whose job is different from the previous job.
Employee name in employees table and job history in job_history table.
I think the following query will help. (I am considering that current JOB_ID is present in the EMPLOYEES table and you want to compare it with the latest previous JOB_ID from JOB_HISTORY table for the employee)
SELECT E.*, JH.LATEST_PREV_JOB_ID
FROM EMPLOYEES E
JOIN (SELECT FIRST_VALUE(JH.JOB_ID) OVER (PARTITION BY JH.EMPLOYEE_ID
ORDER BY JH.START_DATE DESC NULLS LAST) AS LATEST_PREV_JOB_ID,
JH.EMPLOYEE_ID
FROM JOB_HISTORY JH) JH
ON E.EMPLOYEE_ID = JH.EMPLOYEE_ID
WHERE E.JOB_ID <> JH.LATEST_PREV_JOB_ID
----- Update
You want the query without partition by clause (i.e. without WINDOWS function), We can use the NOT EXISTS as follows:
SELECT E.*, JH.LATEST_PREV_JOB_ID
FROM EMPLOYEES E
JOIN (SELECT JH.JOB_ID AS LATEST_PREV_JOB_ID,
JH.EMPLOYEE_ID
FROM JOB_HISTORY JH
WHERE NOT EXISTS (SELECT 1 FROM JOB_HISTORY JHIN
WHERE JHIN.EMPLOYEE_ID = JH.EMPLOYEE_ID
AND JHIN.START_DATE > JH.START_DATE)) JH
ON E.EMPLOYEE_ID = JH.EMPLOYEE_ID
WHERE E.JOB_ID <> JH.LATEST_PREV_JOB_ID
If I understood right your question, then the answer maybe something like this:
select
e.first_name,
e.last_name,
e.job_id as prev_job,
jh.job_id as last_lob
from
employees e,
job_history jh,
(select
employee_id,
max(end_date) as max_end_date
from
job_history
group by
employee_id
) t
where
(jh.employee_id = e.employee_id) and
(jh.job_id <> e.job_id) and
(jh.end_date = t.max_end_date) and
(t.employee_id = jh.employee_id)

How to group by with union in laravel

I have two table that I want to union and after I union them I want to groupBy the one column that I used in union
Here is what I tried:
$issuance = DB::table('issuance as i')
->select('i.issue_to as stud_id', 'i.created_on');
$stud= DB::table('transfer as t')
->select('t.transfer_to as stud_id', 't.created_on')
->union($issuance)
->select('stud_id', 'created_on', DB::raw('COUNT(*) as total_asset'))
->groupBy('stud_id')
->orderBy('created_on', 'DESC')->get();
This is the MySQL query in what I tried
"(select `stud_id`, `created_on`, COUNT(*) as total_asset from `transfer` as
`t` group by `stud_id`) union (select `i`.`issued_to` as `stud_id`, `i`.`created_on` from
`issuance` as `i`) order by `created_on` desc"
What I really want in MySQL is like this:
select stud_id, count(*) from ((select `t`.`transfered_to` as `stud_id`,
`t`.`created_on` from `transfer` as `t`) union (select `i`.`issued_to` as
`stud_id`, `i`.`created_on`, COUNT(*) as asset from `issuance` as `i`)) as t
group by stud_id order by `created_on` desc
Thank you for the help
//try this example ,it will helps you
$query1 = DB::table('table1')->where(....);
$query2 = DB::table('table2')->where(....);
$data = DB::select(DB::raw('id, MAX(created_at) as max_created_at')>union($query1)->union($query2)->orderBy('max_created_at')->groupBy('id')->get();

Converting Oracle Query to Hive

How can I convert the below query in Oracle to Hive?
SELECT A.EMP_NO, A.LOGIN_TIMESTAMP FROM TABLE1 A, TABLE2 B
WHERE A.EMP_NO = 1234 AND B.EMP_CURR =
(SELECT MIN(EMP_CURR) FROM TABLE2 WHERE EMP_NO = A.EMP_NO AND
LOGIN_TIMESTAMP = A.LOGIN_TIMESTAMP AND EMP_STATUS_CODE <> 'P')
Use dense_rank() to get rows with minimum EMP_CURR:
SELECT A.EMP_NO, A.LOGIN_TIMESTAMP
FROM TABLE1 A
INNER JOIN (select B.*,
dense_rank() over(partition by B.EMP_NO, B.LOGIN_TIMESTAMP order by B.EMP_CURR) rn
from TABLE2 B where EMP_STATUS_CODE <> 'P'
) B
on B.EMP_NO = A.EMP_NO and B.LOGIN_TIMESTAMP = A.LOGIN_TIMESTAMP and B.rn=1
where B.rn=1 and A.EMP_NO = 1234;

ORA-01427 while UPDATE self-join ORACLE

two tables, each has employee_id and manager_id which links to employee_id Tables have different employee_id.
UPDATE employee u
SET u.manager_id = (SELECT m.id
FROM employee e
JOIN old_db.employees oe ON e.last_name = oe.last_name
JOIN old_db.employees om ON oe.manager_id = om.employee_id
INNER JOIN employee m ON m.last_name = om.last_name
WHERE e.id = u.id)
WHERE manager_id IS NULL;
gives
ERROR at line 2:
ORA-01427: single-row subquery returns more than one row
I've tried rownum=1 but this makes all manager_id same.
Select query with one given employee_id returns one value
SQL> SELECT m.id
2 FROM employee e
3 JOIN old_db.employees oe ON e.last_name = oe.last_name
4 JOIN old_db.employees om ON oe.manager_id = om.employee_id
5 INNER JOIN employee m ON m.last_name = om.last_name
6 WHERE e.id = 1805;
ID
----------
1804
Well the root cause of problem is in table employees or in table employee last_name are not unique. And when you join table on last name you get more then one row. You may check it with next query:
SELECT e.id, count(*), count(distinct m.id)
FROM employee e
JOIN old_db.employees oe ON e.last_name = oe.last_name
JOIN old_db.employees om ON oe.manager_id = om.employee_id
INNER JOIN employee m ON m.last_name = om.last_name
GROUP BY e.id;
May be exists more suitable column to join it for example employee_id if so you query may be rewritten to:
UPDATE employee u
SET u.manager_id = (SELECT oe.manager_id
FROM old_db.employees oe
WHERE oe.employee_id = u.id)
WHERE manager_id IS NULL;

List of foreign keys and the tables they reference in Oracle DB

I'm trying to find a query which will return me a list of the foreign keys for a table and the tables and columns they reference. I am half way there with
SELECT a.table_name,
a.column_name,
a.constraint_name,
c.owner
FROM ALL_CONS_COLUMNS A, ALL_CONSTRAINTS C
where A.CONSTRAINT_NAME = C.CONSTRAINT_NAME
and a.table_name=:TableName
and C.CONSTRAINT_TYPE = 'R'
But I still need to know which table and primary key are referenced by this key. How would I get that?
The referenced primary key is described in the columns r_owner and r_constraint_name of the table ALL_CONSTRAINTS. This will give you the info you want:
SELECT a.table_name, a.column_name, a.constraint_name, c.owner,
-- referenced pk
c.r_owner, c_pk.table_name r_table_name, c_pk.constraint_name r_pk
FROM all_cons_columns a
JOIN all_constraints c ON a.owner = c.owner
AND a.constraint_name = c.constraint_name
JOIN all_constraints c_pk ON c.r_owner = c_pk.owner
AND c.r_constraint_name = c_pk.constraint_name
WHERE c.constraint_type = 'R'
AND a.table_name = :TableName
Try this:
select * from all_constraints where r_constraint_name in (select constraint_name
from all_constraints where table_name='YOUR_TABLE_NAME');
Here is an all-purpose script we use that has been incredibly handy.
Save it off so you can execute it directly (#fkeys.sql). It will let you search by Owner and either the Parent or Child table and show foreign key relationships. The current script does explicitly spool to C:\SQLRPTS so you will need to create that folder of change that line to something you want to use.
REM ########################################################################
REM ##
REM ## fkeys.sql
REM ##
REM ## Displays the foreign key relationships
REM ##
REM #######################################################################
CLEAR BREAK
CLEAR COL
SET LINES 200
SET PAGES 54
SET NEWPAGE 0
SET WRAP OFF
SET VERIFY OFF
SET FEEDBACK OFF
break on table_name skip 2 on constraint_name on r_table_name skip 1
column CHILDCOL format a60 head 'CHILD COLUMN'
column PARENTCOL format a60 head 'PARENT COLUMN'
column constraint_name format a30 head 'FK CONSTRAINT NAME'
column delete_rule format a15
column bt noprint
column bo noprint
TTITLE LEFT _DATE CENTER 'FOREIGN KEY RELATIONSHIPS ON &new_prompt' RIGHT 'PAGE:'FORMAT 999 SQL.PNO SKIP 2
SPOOL C:\SQLRPTS\FKeys_&new_prompt
ACCEPT OWNER_NAME PROMPT 'Enter Table Owner (or blank for all): '
ACCEPT PARENT_TABLE_NAME PROMPT 'Enter Parent Table or leave blank for all: '
ACCEPT CHILD_TABLE_NAME PROMPT 'Enter Child Table or leave blank for all: '
select b.owner || '.' || b.table_name || '.' || b.column_name CHILDCOL,
b.position,
c.owner || '.' || c.table_name || '.' || c.column_name PARENTCOL,
a.constraint_name,
a.delete_rule,
b.table_name bt,
b.owner bo
from all_cons_columns b,
all_cons_columns c,
all_constraints a
where b.constraint_name = a.constraint_name
and a.owner = b.owner
and b.position = c.position
and c.constraint_name = a.r_constraint_name
and c.owner = a.r_owner
and a.constraint_type = 'R'
and c.owner like case when upper('&OWNER_NAME') is null then '%'
else upper('&OWNER_NAME') end
and c.table_name like case when upper('&PARENT_TABLE_NAME') is null then '%'
else upper('&PARENT_TABLE_NAME') end
and b.table_name like case when upper('&CHILD_TABLE_NAME') is null then '%'
else upper('&CHILD_TABLE_NAME') end
order by 7,6,4,2
/
SPOOL OFF
TTITLE OFF
SET FEEDBACK ON
SET VERIFY ON
CLEAR BREAK
CLEAR COL
SET PAGES 24
SET LINES 100
SET NEWPAGE 1
UNDEF OWNER
This will travel the hierarchy of foreign keys for a given table and column and return columns from child and grandchild, and all descendant tables. It uses sub-queries to add r_table_name and r_column_name to user_constraints, and then uses them to connect rows.
select distinct table_name, constraint_name, column_name, r_table_name, position, constraint_type
from (
SELECT uc.table_name,
uc.constraint_name,
cols.column_name,
(select table_name from user_constraints where constraint_name = uc.r_constraint_name)
r_table_name,
(select column_name from user_cons_columns where constraint_name = uc.r_constraint_name and position = cols.position)
r_column_name,
cols.position,
uc.constraint_type
FROM user_constraints uc
inner join user_cons_columns cols on uc.constraint_name = cols.constraint_name
where constraint_type != 'C'
)
start with table_name = 'MY_TABLE_NAME' and column_name = 'MY_COLUMN_NAME'
connect by nocycle
prior table_name = r_table_name
and prior column_name = r_column_name;
Here is an another solution. Using sys's default views are so slow (approx 10s in my situation). This is much faster than that (approx. 0.5s).
SELECT
CONST.NAME AS CONSTRAINT_NAME,
RCONST.NAME AS REF_CONSTRAINT_NAME,
OBJ.NAME AS TABLE_NAME,
COALESCE(ACOL.NAME, COL.NAME) AS COLUMN_NAME,
CCOL.POS# AS POSITION,
ROBJ.NAME AS REF_TABLE_NAME,
COALESCE(RACOL.NAME, RCOL.NAME) AS REF_COLUMN_NAME,
RCCOL.POS# AS REF_POSITION
FROM SYS.CON$ CONST
INNER JOIN SYS.CDEF$ CDEF ON CDEF.CON# = CONST.CON#
INNER JOIN SYS.CCOL$ CCOL ON CCOL.CON# = CONST.CON#
INNER JOIN SYS.COL$ COL ON (CCOL.OBJ# = COL.OBJ#) AND (CCOL.INTCOL# = COL.INTCOL#)
INNER JOIN SYS.OBJ$ OBJ ON CCOL.OBJ# = OBJ.OBJ#
LEFT JOIN SYS.ATTRCOL$ ACOL ON (CCOL.OBJ# = ACOL.OBJ#) AND (CCOL.INTCOL# = ACOL.INTCOL#)
INNER JOIN SYS.CON$ RCONST ON RCONST.CON# = CDEF.RCON#
INNER JOIN SYS.CCOL$ RCCOL ON RCCOL.CON# = RCONST.CON#
INNER JOIN SYS.COL$ RCOL ON (RCCOL.OBJ# = RCOL.OBJ#) AND (RCCOL.INTCOL# = RCOL.INTCOL#)
INNER JOIN SYS.OBJ$ ROBJ ON RCCOL.OBJ# = ROBJ.OBJ#
LEFT JOIN SYS.ATTRCOL$ RACOL ON (RCCOL.OBJ# = RACOL.OBJ#) AND (RCCOL.INTCOL# = RACOL.INTCOL#)
WHERE CONST.OWNER# = userenv('SCHEMAID')
AND RCONST.OWNER# = userenv('SCHEMAID')
AND CDEF.TYPE# = 4 /* 'R' Referential/Foreign Key */;
If you need all the foreign keys of the user then use the following script
SELECT a.constraint_name, a.table_name, a.column_name, c.owner,
c_pk.table_name r_table_name, b.column_name r_column_name
FROM user_cons_columns a
JOIN user_constraints c ON a.owner = c.owner
AND a.constraint_name = c.constraint_name
JOIN user_constraints c_pk ON c.r_owner = c_pk.owner
AND c.r_constraint_name = c_pk.constraint_name
JOIN user_cons_columns b ON C_PK.owner = b.owner
AND C_PK.CONSTRAINT_NAME = b.constraint_name AND b.POSITION = a.POSITION
WHERE c.constraint_type = 'R'
based on Vincent Malgrat code
I know it's kinda late to answer but let me answer anyway, some of the answers
above are quite complicated hence here is a much simpler take.
SELECT a.table_name child_table, a.column_name child_column, a.constraint_name,
b.table_name parent_table, b.column_name parent_column
FROM all_cons_columns a
JOIN all_constraints c ON a.owner = c.owner AND a.constraint_name = c.constraint_name
join all_cons_columns b on c.owner = b.owner and c.r_constraint_name = b.constraint_name
WHERE c.constraint_type = 'R'
AND a.table_name = 'your table name'
My version, in my humble opinion, more readable:
SELECT PARENT.TABLE_NAME "PARENT TABLE_NAME"
, PARENT.CONSTRAINT_NAME "PARENT PK CONSTRAINT"
, '->' " "
, CHILD.TABLE_NAME "CHILD TABLE_NAME"
, CHILD.COLUMN_NAME "CHILD COLUMN_NAME"
, CHILD.CONSTRAINT_NAME "CHILD CONSTRAINT_NAME"
FROM ALL_CONS_COLUMNS CHILD
, ALL_CONSTRAINTS CT
, ALL_CONSTRAINTS PARENT
WHERE CHILD.OWNER = CT.OWNER
AND CT.CONSTRAINT_TYPE = 'R'
AND CHILD.CONSTRAINT_NAME = CT.CONSTRAINT_NAME
AND CT.R_OWNER = PARENT.OWNER
AND CT.R_CONSTRAINT_NAME = PARENT.CONSTRAINT_NAME
AND CHILD.TABLE_NAME = ::table -- table name variable
AND CT.OWNER = ::owner; -- schema variable, could not be needed
Its a bit late to anwser, but I hope my answer been useful for someone, who needs to select Composite foreign keys.
SELECT
"C"."CONSTRAINT_NAME",
"C"."OWNER" AS "SCHEMA_NAME",
"C"."TABLE_NAME",
"COL"."COLUMN_NAME",
"REF_COL"."OWNER" AS "REF_SCHEMA_NAME",
"REF_COL"."TABLE_NAME" AS "REF_TABLE_NAME",
"REF_COL"."COLUMN_NAME" AS "REF_COLUMN_NAME"
FROM
"USER_CONSTRAINTS" "C"
INNER JOIN "USER_CONS_COLUMNS" "COL" ON "COL"."OWNER" = "C"."OWNER"
AND "COL"."CONSTRAINT_NAME" = "C"."CONSTRAINT_NAME"
INNER JOIN "USER_CONS_COLUMNS" "REF_COL" ON "REF_COL"."OWNER" = "C"."R_OWNER"
AND "REF_COL"."CONSTRAINT_NAME" = "C"."R_CONSTRAINT_NAME"
AND "REF_COL"."POSITION" = "COL"."POSITION"
WHERE "C"."TABLE_NAME" = 'TableName' AND "C"."CONSTRAINT_TYPE" = 'R'
SELECT a.table_name, a.column_name, a.constraint_name, c.owner,
-- referenced pk
c.r_owner, c_pk.table_name r_table_name, c_pk.constraint_name r_pk
FROM all_cons_columns a
JOIN all_constraints c ON a.owner = c.owner
AND a.constraint_name = c.constraint_name
JOIN all_constraints c_pk ON c.r_owner = c_pk.owner
AND c.r_constraint_name = c_pk.constraint_name
WHERE c.constraint_type = 'R'
AND a.table_name :=TABLE_NAME
AND c.owner :=OWNER_NAME;
In case one wants to create FK constraints from UAT environment table to Live, fire below dynamic query.....
SELECT 'ALTER TABLE '||OBJ.NAME||' ADD CONSTRAINT '||CONST.NAME||' FOREIGN KEY ('||COALESCE(ACOL.NAME, COL.NAME)||') REFERENCES '
||ROBJ.NAME ||' ('||COALESCE(RACOL.NAME, RCOL.NAME) ||');'
FROM SYS.CON$ CONST
INNER JOIN SYS.CDEF$ CDEF ON CDEF.CON# = CONST.CON#
INNER JOIN SYS.CCOL$ CCOL ON CCOL.CON# = CONST.CON#
INNER JOIN SYS.COL$ COL ON (CCOL.OBJ# = COL.OBJ#) AND (CCOL.INTCOL# = COL.INTCOL#)
INNER JOIN SYS.OBJ$ OBJ ON CCOL.OBJ# = OBJ.OBJ#
LEFT JOIN SYS.ATTRCOL$ ACOL ON (CCOL.OBJ# = ACOL.OBJ#) AND (CCOL.INTCOL# = ACOL.INTCOL#)
INNER JOIN SYS.CON$ RCONST ON RCONST.CON# = CDEF.RCON#
INNER JOIN SYS.CCOL$ RCCOL ON RCCOL.CON# = RCONST.CON#
INNER JOIN SYS.COL$ RCOL ON (RCCOL.OBJ# = RCOL.OBJ#) AND (RCCOL.INTCOL# = RCOL.INTCOL#)
INNER JOIN SYS.OBJ$ ROBJ ON RCCOL.OBJ# = ROBJ.OBJ#
LEFT JOIN SYS.ATTRCOL$ RACOL ON (RCCOL.OBJ# = RACOL.OBJ#) AND (RCCOL.INTCOL# = RACOL.INTCOL#)
WHERE CONST.OWNER# = userenv('SCHEMAID')
AND RCONST.OWNER# = userenv('SCHEMAID')
AND CDEF.TYPE# = 4
AND OBJ.NAME = <table_name>;
I used below code and it served my purpose-
SELECT fk.owner, fk.table_name, col.column_name
FROM dba_constraints pk, dba_constraints fk, dba_cons_columns col
WHERE pk.constraint_name = fk.r_constraint_name
AND fk.constraint_name = col.constraint_name
AND pk.owner = col.owner
AND pk.owner = fk.owner
AND fk.constraint_type = 'R'
AND pk.owner = sys_context('USERENV', 'CURRENT_SCHEMA')
AND pk.table_name = :my_table
AND pk.constraint_type = 'P';
select d.table_name,
d.constraint_name "Primary Constraint Name",
b.constraint_name "Referenced Constraint Name"
from user_constraints d,
(select c.constraint_name,
c.r_constraint_name,
c.table_name
from user_constraints c
where table_name='EMPLOYEES' --your table name instead of EMPLOYEES
and constraint_type='R') b
where d.constraint_name=b.r_constraint_name
WITH reference_view AS
(SELECT a.owner, a.table_name, a.constraint_name, a.constraint_type,
a.r_owner, a.r_constraint_name, b.column_name
FROM dba_constraints a, dba_cons_columns b
WHERE a.owner LIKE UPPER ('SYS') AND
a.owner = b.owner
AND a.constraint_name = b.constraint_name
AND constraint_type = 'R'),
constraint_view AS
(SELECT a.owner a_owner, a.table_name, a.column_name, b.owner b_owner,
b.constraint_name
FROM dba_cons_columns a, dba_constraints b
WHERE a.owner = b.owner
AND a.constraint_name = b.constraint_name
AND b.constraint_type = 'P'
AND a.owner LIKE UPPER ('SYS')
)
SELECT
rv.table_name FK_Table , rv.column_name FK_Column ,
CV.table_name PK_Table , rv.column_name PK_Column , rv.r_constraint_name Constraint_Name
FROM reference_view rv, constraint_view CV
WHERE rv.r_constraint_name = CV.constraint_name AND rv.r_owner = CV.b_owner;
For Load UserTable (List of foreign keys and the tables they reference)
WITH
reference_view AS
(SELECT a.owner, a.table_name, a.constraint_name, a.constraint_type,
a.r_owner, a.r_constraint_name, b.column_name
FROM dba_constraints a, dba_cons_columns b
WHERE
a.owner = b.owner
AND a.constraint_name = b.constraint_name
AND constraint_type = 'R'),
constraint_view AS
(SELECT a.owner a_owner, a.table_name, a.column_name, b.owner b_owner,
b.constraint_name
FROM dba_cons_columns a, dba_constraints b
WHERE a.owner = b.owner
AND a.constraint_name = b.constraint_name
AND b.constraint_type = 'P'
) ,
usertableviewlist AS
(
select TABLE_NAME from user_tables
)
SELECT
rv.table_name FK_Table , rv.column_name FK_Column ,
CV.table_name PK_Table , rv.column_name PK_Column , rv.r_constraint_name Constraint_Name
FROM reference_view rv, constraint_view CV , usertableviewlist UTable
WHERE rv.r_constraint_name = CV.constraint_name AND rv.r_owner = CV.b_owner And UTable.TABLE_NAME = rv.table_name;
The more simple solution:
SELECT *
FROM all_indexes
WHERE index_name like '%FK_PROCESS%'

Resources