当前位置:网站首页>[Dameng database] after backup and recovery, two SQL statements should be executed

[Dameng database] after backup and recovery, two SQL statements should be executed

2022-07-07 03:17:00 E-cology

After restoring the database, there are sometimes stored procedures 、 Triggers, etc. are not running , It needs to be recompiled .
The second is to update the statistical information .
Compile database stored procedures , trigger , View objects . Please be there. ecology Execute under the user of .


declare
sql_v  varchar(8000);
ex_sql varchar(4000);
begin
        for i in
        (
                select 'alter procedure '||OBJECT_NAME as object_new from USER_PROCEDURES
                union all
                select 'alter trigger '||TRIGGER_NAME from USER_TRIGGERS
                union all
                select 'alter view '||VIEW_NAME from USER_VIEWS
        )      
        loop
         BEGIN
                sql_v:=i.object_new||' compile;';
                -- print(sql_v);
                execute immediate sql_v;
        EXCEPTION
        WHEN OTHERS THEN
                 ex_sql:='insert into ex_table value('||i.object_new||',''00'',''00'');';
                print ex_sql;
        end;
        end loop;
end;

     

----SQL2:  Update statistics for the entire database 

    CALL SP_DB_STAT_INIT();
原网站

版权声明
本文为[E-cology]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207061954409364.html