Oracle Locks Temporary Table statistics

Source: Internet
Author: User

The statistics of the global temporary table cannot be collected, if it is collected, its statistic is definitely 0, it will cause the execution plan is not allowed, so we should lock up its statistic information and prevent the system from collecting automatically.

-- Unlock the table statistics First, then delete the table statistics, and finally lock the table statistics

Declare

V_sql varchar2 (a);

cursor rowList1 is

Select' Begin dbms_stats.unlock_table_stats (user, ' ' | | table_name | | "); End; '

from user_tables s

where s.temporary = ' Y ';

cursor rowList2 is

Select' Begin dbms_stats.delete_table_stats (user, ' ' | | table_name | | "); End; '

from user_tables s

where s.temporary = ' Y ';

cursor rowList3 is

Select' Begin dbms_stats.lock_table_stats (user, ' ' | | table_name | | "); End; '

from user_tables s

where s.temporary = ' Y ';

Begin

Open rowList1;

Open rowList2;

Open rowList3;

Loop

fetch rowList1 into v_sql;

Executeimmediate v_sql;

exit when rowlist1%notfound;

Endloop;

Loop

fetch rowList2 into v_sql;

Executeimmediate v_sql;

exit when rowlist2%notfound;

Endloop;

Loop

fetch rowList3 into v_sql;

Executeimmediate v_sql;

exit when rowlist3%notfound;

Endloop;

close rowList1;

close rowList2;

close rowList3;

End ;

-- stattype_locked= ' All ' It means that the statistics of the table are locked

Select s.table_name,s.stattype_locked from user_tab_statistics s where s.stattype_locked= ' All ' ;

Oracle Locks Temporary Table statistics

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.