giovedì 17 febbraio 2011

Export tabella in CSV

Il seguente comando permette di esportare una tabella MySQL in CSV:

mysqldump \
  -c \
  -T/tmp \
  -h localhost \
  --user=root \
  --password=<pwd> \
  --fields-enclosed-by=\" \
  --fields-terminated-by=, \
  <db> \
  <table>

lunedì 14 febbraio 2011

Statische occupazione dati

La seguente query estrae la dimensione dei dati, degli indici e dei database presenti su MySQL:

SELECT table_schema "Data Base Name",
       sum(data_length) / 1024 / 1024 "Data Size in MB",
       sum(index_length) / 1024 /1024 "Index Size in MB",
       sum( data_length + index_length) / 1024 / 1024 "Data Base Size in MB"
  FROM information_schema.TABLES
 GROUP BY table_schema;