More MySQL tips. Listing databases and viewing the MySQL version.

Posted: August 30, 2012. At: 9:30 PM. This was 5 years ago. Post ID: 4513

How to list tables in a MySQL database.

mysql> show tables in acme;
+----------------+
| Tables_in_acme |
+----------------+
| address        |
| customer       |
| discount       |
| order_header   |
| order_line     |
| order_shipment |
| payment_terms  |
| phone          |
| product        |
| reseller       |
| salesman       |
| shipment       |
| status         |
+----------------+
13 rows in set (0.00 sec)

mysql>

Listing the databases in your MySQL installation.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| acme               |
| fun                |
| mysql              |
| performance_schema |
| test               |
+--------------------+
6 rows in set (0.00 sec)

mysql>

How to get the MySQL version with SQL.

mysql> select @@version;
+-------------------------+
| @@version               |
+-------------------------+
| 5.5.24-0ubuntu0.12.04.1 |
+-------------------------+
1 row in set (0.00 sec)

No comments have been made. Use this form to start the conversation :)

Leave a Reply