达梦数据库临时禁用所有约束、存储过程和触发器

一、批量执行SQL的方式

(1)禁用/启用所有外键

--禁用
SELECT
    'ALTER TABLE ' || OWNER || '.' || TABLE_NAME || ' DISABLE CONSTRAINT ' || CONSTRAINT_NAME || ';'
FROM
    SYS.DBA_CONSTRAINTS
WHERE
    OWNER NOT LIKE 'SYS%'
    AND CONSTRAINT_TYPE = 'R';
--启用
SELECT
    'ALTER TABLE ' || OWNER || '.' || TABLE_NAME || ' ENABLE CONSTRAINT ' || CONSTRAINT_NAME || ';'
FROM
    SYS.DBA_CONSTRAINTS
WHERE
    OWNER NOT LIKE 'SYS%'
    AND CONSTRAINT_TYPE = 'R';

(2)重新编译存储过程

SELECT 'ALTER PROCEDURE '||OWNER||'.'||OBJECT_NAME|| ' COMPILE DEBUG;' FROM SYS.DBA_PROCEDURES WHERE OWNER NOT LIKE 'SYS%';

(3)禁用/启用所有触发器

--禁用
SELECT
    'ALTER TRIGGER ' || OWNER || '.' || TRIGGER_NAME || ' DISABLE;'
FROM
    SYS.DBA_TRIGGERS
WHERE
    OWNER NOT LIKE 'SYS%'
    AND TRIGGER_NAME NOT LIKE 'SREF_CON_%';
--启用
SELECT
    'ALTER TRIGGER ' || OWNER || '.' || TRIGGER_NAME || ' ENABLE;'
FROM
    SYS.DBA_TRIGGERS
WHERE
    OWNER NOT LIKE 'SYS%'
    AND TRIGGER_NAME NOT LIKE 'SREF_CON_%';

(4)重新编译触发器

SELECT 'ALTER TRIGGER '||OWNER||'.'||TRIGGER_NAME|| ' COMPILE DEBUG;' FROM SYS.DBA_TRIGGERS WHERE OWNER NOT LIKE 'SYS%';

二、会话级别

(1)禁用约束

SET_SESSION_CONS_CHK(0)

(2)禁用触发器

SET_SESSION_TRIGGER_CHECK(0)
暂无评论

发送评论 编辑评论


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇