Pular para o conteúdo

Fóruns Banco de dados Oracle Enable Constraint Enable Constraint

#86230
David Siqueira
Participante

    Fica com esse script ai na manga :

    Accep own prompt "Entre com o Owner....:"
    accep tbs prompt "Entre com a tabela ...:"

    set linesize 1000
    set pagesize 0
    set feedback off
    spool enable_constraints.out

    prompt ---- Check Constraints

    select ' alter table '||owner||'.'||table_name||' enable novalidate constraint '||constraint_name||';'
    from dba_constraints
    where owner like upper(nvl ('%&OWN%',OWNER))
    and constraint_type='C'
    and status != 'ENABLED'
    and table_name like upper(nvl('%&tbs%',TABLE_NAME));

    prompt ---- Unique Constraints

    select ' alter table '||owner||'.'||table_name||' enable novalidate constraint '||constraint_name||';'
    from dba_constraints
    where owner like upper(nvl ('%&OWN%',OWNER))
    and constraint_type='U'
    and status != 'ENABLED'
    and table_name like upper(nvl('%&tbs%',TABLE_NAME));

    prompt ---- Primary Constraints

    select ' alter table '||owner||'.'||table_name||' enable novalidate constraint '||constraint_name||';'
    from dba_constraints
    where owner like upper(nvl ('%&OWN%',OWNER))
    and constraint_type='P'
    and status != 'ENABLED'
    and table_name like upper(nvl('%&tbs%',TABLE_NAME));

    prompt ---- Referential Constraints

    select ' alter table '||owner||'.'||table_name||' enable novalidate constraint '||constraint_name||';'
    from dba_constraints
    where owner like upper(nvl ('%&OWN%',OWNER))
    and constraint_type='R'
    and status != 'ENABLED'
    and table_name like upper(nvl('%&tbs%',TABLE_NAME));

    spool off

    Abraço.

    David