MySQL對所有表收集統計資訊(Python 2指令碼)
-
[root@MySQL01 script]# vim analyze.py
-
#!/usr/bin/env python
-
# -*-encoding:utf8-*-
-
#
-
-
import MySQLdb
-
import time
-
step = 0
-
db = MySQLdb.connect(host = '192.168.56.101',port = 3306,user = 'neo', passwd = 'neo' , db = 'information_schema')
-
conn = db.cursor()
-
-
sql = '''select TABLE_SCHEMA, table_name from information_schema.tables where table_schema not in ('information_schema', 'performance_schema', 'mysql') '''
-
# print sql
-
conn.execute(sql)
-
if conn.rowcount > 0:
-
for item in conn.fetchall():
-
sql = '''analyze table %s.%s''' % (item[0], item[1])
-
print sql + ' operation executes successfully!'
-
conn.execute(sql)
-
-
time.sleep(0.5)
-
-
conn.close()
-
db.close()
-
-
# 執行指令碼
-
[root@MySQL01 script]# python2.6 analyze.py
-
analyze table test.area operation executes
- analyze table test.class operation executes
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2152815/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【TABLE】Oracle表資訊收集指令碼Oracle指令碼
- Oracle運維指令碼-收集統計資訊Oracle運維指令碼
- Oracle 11g 統計資訊收集指令碼Oracle指令碼
- mysql如收集統計資訊MySql
- MySQL 5.5 統計資訊收集MySql
- Oracle 判斷 並 手動收集 統計資訊 指令碼Oracle指令碼
- MySQL系統如何收集統計資訊MySql
- 表統計資訊匯出匯入指令碼指令碼
- 微課sql最佳化(3)、統計資訊收集(2)-如何收集統計資訊SQL
- Fixed Objects Statistics統計資訊收集 - 2Object
- 收集統計資訊的SQL指令碼(sosi.sql)--崔華大師SQL指令碼
- 重新收集oracle表的統計資訊Oracle
- 利用PHP指令碼刪除MySQL上所有的表PHP指令碼MySql
- 透過Python進行MySQL表資訊統計PythonMySql
- 10g_crt_gather_table_stats(生成表的統計資訊收集指令碼,關鍵在引數)指令碼
- 9i_crt_gather_table_stats(生成表的統計資訊收集指令碼,關鍵在引數)指令碼
- Oracle 11g手工收集表統計資訊Oracle
- DB2_收集表統計資料DB2
- Oracle收集統計資訊Oracle
- Oracle 統計資訊收集Oracle
- 收集oracle統計資訊Oracle
- ORACLE 收集統計資訊Oracle
- oracle外部表建立以及收集統計資訊以及臨時表Oracle
- 【統計資訊】Oracle常用的收集統計資訊方式Oracle
- 通過shell指令碼生成資料統計資訊的報表指令碼
- 透過shell指令碼生成資料統計資訊的報表指令碼
- 收集全庫統計資訊
- 【SCRIPT】Oracle資料庫基本資訊收集指令碼Oracle資料庫指令碼
- 收集資料庫統計資訊需要收集直方圖資訊.資料庫直方圖
- 全域性臨時表GTT的統計資訊收集辦法:
- Oracle統計資訊自動收集Oracle
- oracle收集統計資訊job停止Oracle
- 【統計資訊】全面檢視錶所有統計資訊SQLSQL
- [指令碼例項]——統計系統資訊指令碼指令碼
- SQL Server 監控統計阻塞指令碼資訊SQLServer指令碼
- 檢視錶的統計資訊SQL指令碼SQL指令碼
- oracle 統計資訊檢視與收集Oracle
- 6 收集資料庫統計資訊資料庫