select TABLE_NAME,CONSTRAINT_NAMEs
from (
select TABLE_NAME,CONSTRAINT_NAMEs, row_number() over(partition by TABLE_NAME order by TABLE_NAME,curr_level desc) CONSTRAINT_NAMEs_rank
from (
select TABLE_NAME,CONSTRAINT_NAME,rank,level as curr_level,ltrim(sys_connect_by_path(CONSTRAINT_NAME,','),',') CONSTRAINT_NAMEs
from (
select CONSTRAINT_NAME,TABLE_NAME,row_number() over(partition by TABLE_NAME order by TABLE_NAME,CONSTRAINT_NAME) rank
from (
select distinct CONSTRAINT_NAME,TABLE_NAME from USER_CONSTRAINTS t
) order by TABLE_NAME,CONSTRAINT_NAME
) connect by TABLE_NAME = prior TABLE_NAME and rank-1 = prior rank
)
)
where CONSTRAINT_NAMEs_rank=1;
from (
select TABLE_NAME,CONSTRAINT_NAMEs, row_number() over(partition by TABLE_NAME order by TABLE_NAME,curr_level desc) CONSTRAINT_NAMEs_rank
from (
select TABLE_NAME,CONSTRAINT_NAME,rank,level as curr_level,ltrim(sys_connect_by_path(CONSTRAINT_NAME,','),',') CONSTRAINT_NAMEs
from (
select CONSTRAINT_NAME,TABLE_NAME,row_number() over(partition by TABLE_NAME order by TABLE_NAME,CONSTRAINT_NAME) rank
from (
select distinct CONSTRAINT_NAME,TABLE_NAME from USER_CONSTRAINTS t
) order by TABLE_NAME,CONSTRAINT_NAME
) connect by TABLE_NAME = prior TABLE_NAME and rank-1 = prior rank
)
)
where CONSTRAINT_NAMEs_rank=1;