select --'truncate table '|| TABLE_NAME || ';' 'alter table ' || TABLE_NAME || ' enable constraint ' || CONSTRAINT_NAME || ';' from ALL_CONSTRAINTS where CONSTRAINT_TYPE = 'R' and STATUS <> 'ENABLED' --and R_CONSTRAINT_NAME = 'C_MEDHISTCONS_PK' order by TABLE_NAME select 'alter table ' || TABLE_NAME || ' disable constraint ' || CONSTRAINT_NAME || ';' from ALL_CONSTRAINTS where CONSTRAINT_TYPE = 'R' and R_CONSTRAINT_NAME = 'C_DCSPECS_PK'
пятница, 31 июля 2015 г.
How to disable and enable depended constraints
вторник, 28 июля 2015 г.
How to create indexes by foreign key
select 'create index I_' || substr(C.CONSTRAINT_NAME, 3) || ' on ' || C.TABLE_NAME || '(' ||
(select rtrim(xmlagg(xmlelement(e, CC.COLUMN_NAME,',').extract('//text()') order by CC.COLUMN_NAME).GetClobVal(),',')
from ALL_CONS_COLUMNS CC
where CC.OWNER = C.OWNER
and CC.TABLE_NAME = C.TABLE_NAME
and CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME) || ');'
from (
select distinct C.OWNER, C.TABLE_NAME, C.CONSTRAINT_NAME
from
ALL_CONSTRAINTS C,
ALL_CONS_COLUMNS CC
where C.CONSTRAINT_TYPE = 'R'
and C.OWNER = 'PARUS'
and CC.OWNER = C.OWNER
and CC.TABLE_NAME = C.TABLE_NAME
and CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME
and not CC.COLUMN_NAME in ('COMPANY', 'VERSION')
and CC.CONSTRAINT_NAME like 'C\_%' escape '\'
and not exists (
select *
from ALL_IND_COLUMNS IC
where IC.TABLE_OWNER = C.OWNER
and IC.TABLE_NAME = CC.TABLE_NAME
and IC.COLUMN_NAME = CC.COLUMN_NAME)) C
пятница, 10 июля 2015 г.
How to reverse string
select listagg(C) within group(order by RN desc) rvs from ( select substr(T.COL, rownum, 1) C, rownum RN from (select 'Привет' COL from DUAL) T connect by level <= length(T.COL))
Подписаться на:
Сообщения (Atom)