Difference: MySQL (2 vs. 3)

Revision 32010-10-23 - ChrisNell

Line: 1 to 1
 
META TOPICPARENT name="EmpiricalAlgorithmics"

Useful SQL

Getting information

Line: 8 to 8
 
    • select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='MY_DB_NAME';
  • See what processes are running
    • SHOW [FULL] PROCESSLIST;
Added:
>
>
  • Get size of all databases
    • SELECT table_schema "Database Name", sum( data_length + index_length) / 1024 / 1024 "Database Size in MB" FROM information_schema.TABLES GROUP BY table_schema;
  • Get size breakdown for a single database named "my_database"
    • SELECT table_name, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024),2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "my_database";
 

Backing up and moving

  • Copy a table
    • CREATE TABLE NEW_TABLE SELECT * FROM OLD_TABLE ;
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback