| | |
Analyze all tables in a database?
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 79
Reputation:
Solved Threads: 8
You can do it by a sp or from Mysql Administrator
I generally do it from Sp
I generally do it from Sp
sql Syntax (Toggle Plain Text)
DELIMITER $$ DROP PROCEDURE IF EXISTS `reports`.`SP_Mysql_Maintance_Plan_Optimize_Tables`$$ CREATE PROCEDURE `SP_Mysql_Maintance_Plan_Optimize_Tables`() BEGIN DECLARE l_loop_end INT DEFAULT 0; DECLARE IN_TABLE_SCHEMA VARCHAR(100); DECLARE IN_TABLE_NAME VARCHAR(100); DECLARE CUR1 CURSOR FOR SELECT TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('TEST','information_schema'); DECLARE continue HANDLER for sqlstate '02000' SET l_loop_end = 1; open CUR1; REPEAT FETCH cur1 INTO IN_TABLE_SCHEMA,IN_TABLE_NAME; if NOT l_loop_end THEN SELECT '' AS ''; SELECT CONCAT('DATABASE NAME: ' ,IN_TABLE_SCHEMA,' TABLE NAME : ',IN_TABLE_NAME) AS ''; SELECT CONCAT('START TIME: ',NOW()) as ''; SET @qry = CONCAT('OPTIMIZE TABLE ', IN_TABLE_SCHEMA, '.',IN_TABLE_NAME); PREPARE stmt FROM @qry; EXECUTE stmt; DEALLOCATE PREPARE stmt; SELECT CONCAT('END TIME: ',NOW()) AS ''; SELECT '' AS ''; END if; until l_loop_end END REPEAT; close cur1; END$$ DELIMITER ;
Last edited by peter_budo; Feb 10th, 2009 at 8:30 am. Reason: Please use [code] instead of [quote] tag
:- Varma
We are Happy to inform launch of a new site with loads of database related information Site offers wide range of functionality Forums,Blogs,Articles,Editorials and much more
http://www.sqllibrarian.info/
We are Happy to inform launch of a new site with loads of database related information Site offers wide range of functionality Forums,Blogs,Articles,Editorials and much more
http://www.sqllibrarian.info/
![]() |
Similar Threads
Other Threads in the MySQL Forum
- Previous Thread: need help, please!
- Next Thread: Mysql and php optimization please!!! :(
| Thread Tools | Search this Thread |
Tag cloud for MySQL
"use" 1 agplv3 alfresco amazon api artisticlicense aws bizspark camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright court crm data database design developer development distinct dui ec2 eliminate enter enterprise error facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword kickfire laptop legal license licensing linux maintenance mariadb matchingcolumns metron microsoft microsoftexchange mindtouch mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource operand oracle penelope php priceupdating query referencedesign remove reorderingcolumns saas search select sharepoint simpledb spotify statement sugarcrm syntax techsupport thunderbird update virtualization





