We moved this page to our Documentation Portal. You can find the latest updates here. |
Question
How to show all table content in MySQL?
Environment
All OnApp Versions
Answer
To display all tables in MySQL, run the command below:
show tables;
To display all fields in a table:
explain <tablename>;
Example:
mysql> explain templates;
+-----------------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| label | varchar(255) | YES | | NULL | |
| created_at | datetime | YES | | NULL | |
| updated_at | datetime | YES | | NULL | |
| version | varchar(255) | YES | | NULL | |
| file_name | varchar(255) | YES | | NULL | |
| operating_system | varchar(255) | YES | | NULL | |
| operating_system_distro | varchar(255) | YES | | NULL | |
| allowed_swap | tinyint(1) | YES | | 1 | |
| state | varchar(255) | YES | | pending | |
| checksum | varchar(255) | YES | | NULL | |
| allow_resize_without_reboot | tinyint(1) | YES | | NULL | |
| min_disk_size | int(11) | YES | | NULL | |
| user_id | int(11) | YES | MUL | NULL | |
| template_size | int(11) | YES | | NULL | |
| allowed_hot_migrate | tinyint(1) | YES | | 0 | |
| operating_system_arch | varchar(255) | YES | | NULL | |
| operating_system_edition | varchar(255) | YES | | NULL | |
| operating_system_tail | varchar(255) | YES | | NULL | |
| parent_template_id | int(11) | YES | | NULL | |
| virtualization | varchar(255) | YES | | NULL | |
| min_memory_size | int(11) | YES | | NULL | |
| disk_target_device | varchar(255) | YES | | NULL | |
| cdn | tinyint(1) | YES | | 0 | |
+-----------------------------+--------------+------+-----+---------+----------------+
24 rows in set (0.00 sec)
You can then use SELECT queries to find the needed information:
SELECT id, label, file_name, template_size FROM templates WHERE operating_system='linux';
Additional Information
Please refer to this article for help with logging into the MySQL server:
https://onapp.zendesk.com/entries/22073502-mysql-how-to-access-the-mysql-database-in-onapp
The MySQL documentation is also a good place to read more about MySQL commands:
http://dev.mysql.com/doc/