Home  Home  Home  Kontakt  Kontakt  Kontakt  Inhalt  Inhalt  Inhalt  Blog  Blog  Blog  FAQ  FAQ  FAQ

Dynamisches SQL

-- Dynamisches SQL:
-- z.B. ALTER TABLE Statements, die danach (via Copy/Paste)
-- ausgeführt werden können
 SELECT CONCAT('ALTER TABLE ', table_schema ,'.',table_name, ' ENGINE=InnoDB;')
   FROM information_schema.tables
   WHERE table_type='BASE TABLE' and engine <> 'InnoDB'
 ;
-- ANALYZE TABLE
SELECT CONCAT('ANALYZE TABLE ', table_schema ,'.',table_name, ' ;')
   FROM information_schema.tables
   WHERE table_schema LIKE '%%'
   ORDER BY table_schema, table_name
 ;

-- ANALYZE TABLE
SELECT CONCAT('ANALYZE NO_WRITE_TO_BINLOG TABLE ', table_schema ,'.',table_name, ' ;')
   FROM information_schema.tables
   WHERE table_schema = DATABASE()
   ORDER BY table_schema, table_name
 ;
SELECT CONCAT('SELECT * FROM ', table_name, ' PROCEDURE ANALYSE() \G')
   FROM information_schema.tables
   WHERE table_schema = DATABASE()
   ORDER BY table_schema, table_name
 ;

SELECT CONCAT('SELECT ', column_name ,' FROM ', table_name, ' PROCEDURE ANALYSE();')
   FROM information_schema.columns
   WHERE table_schema = DATABASE()
   ORDER BY table_schema, table_name, ordinal_position
 ;