Tuesday, April 19, 2016

Mysql Cheat Sheet

To List all the databases, their tables and the number of records in each table


select table_schema,table_name,table_rows from information_schema.tables;

displays in following format

+---------------------------+----------------------------------------------------+------------------+
 | table_schema               | table_name                                                   | table_rows       |
+---------------------------+----------------------------------------------------+------------------+

Note: The table_rows here are approximated rows and may not show the correct number of rows. Be careful.

Extended Display

Select * from abc \G;

\G results in extended display

Dumping database

mysqldump -u<username> -p<password> <db_name>  >   dump.sql

dump.sql will contain the dump of db

No comments:

Post a Comment