Script:
SELECT table_name, partition_name, last_analyzed,
'ANALYZE TABLE ' ||table_owner||'.'
|| table_name
|| ' partition ('
|| partition_name
|| ') ESTIMATE STATISTICS SAMPLE 10 PERCENT;'
script
FROM dba_tab_partitions
WHERE table_owner='BINH_OWNER' and ((TO_DATE(SUBSTR(partition_name,5,8),'YYYYMMDD')> sysdate -15
AND TO_DATE(SUBSTR(partition_name,5,8),'YYYYMMDD')< sysdate
and partition_name LIKE 'DATA' || TO_CHAR (sysdate, 'YYYY')||'%'
AND table_name IN --partitioned via date
('TABLE1',
'TABLE2',
'TABLE3',
'TABLE4',
'TABLE5'))
)
--AND nvl(last_analyzed,sysdate- 30) < sysdate
--and (num_rows is null or num_rows=0)
--AND nvl(last_analyzed,sysdate- 30) < sysdate
and (num_rows is null or num_rows<1000 or last_analyzed is null)
--and last_analyzed is null
ORDER BY partition_name;
Copy và chạy:
ANALYZE TABLE BINH_OWNER.TABLE1 partition (DATA20201102) ESTIMATE STATISTICS SAMPLE 10 PERCENT;
ANALYZE TABLE BINH_OWNER.TABLE2 partition (DATA20201102) ESTIMATE STATISTICS SAMPLE 10 PERCENT;
ANALYZE TABLE BINH_OWNER.TABLE3 partition (DATA20201102) ESTIMATE STATISTICS SAMPLE 10 PERCENT;
ANALYZE TABLE BINH_OWNER.TABLE4 partition (DATA20201102) ESTIMATE STATISTICS SAMPLE 10 PERCENT;
ANALYZE TABLE BINH_OWNER.TABLE5 partition (DATA20201102) ESTIMATE STATISTICS SAMPLE 10 PERCENT;
Kiểm tra lại:
select * from dba_tab_partitions where table_name IN
('TABLE1',
'TABLE2',
'TABLE3',
'TABLE4',
'TABLE5');
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile: 0902912888
⚡️ Skype: tranbinh48ca
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội
#OracleTutorial #OracleDBA #OracleDatabaseAdministration #học oracle database #oca #ocp #tự học oracle