MoonPoint Support Logo

 


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
August
Sun Mon Tue Wed Thu Fri Sat
           
31          
2015
Months
Aug


Mon, Aug 31, 2015 10:28 pm

Viewing information about MySQL and MariaDB databases and tables

MySQL and MariaDB, which is a fork of MySQL are relational database management systems that share a common command syntax. For both, you can see available databases with the command show databases.
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ann                |
| crystal            |
| grover             |
| horticulture       |
| justiceleague      |
| maker              |
| mars               |
| moon               |
| orwell             |
+--------------------+
10 rows in set (0.09 sec)

MariaDB [(none)]>

You can see the tables within a particular database by selecing the database with use dbname, where dbname is the name of the database, and then using show tables;.

MariaDB [(none)]> use crystal
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [crystal]> show tables;
+---------------------------+
| Tables_in_crystaltokyo    |
+---------------------------+
| smf_admin_info_files      |
| smf_approval_queue        |
| smf_attachments           |
| smf_ban_groups            |
| smf_ban_items             |
| smf_board_permissions     |
| smf_boards                |
| smf_buddies               |
| smf_calendar              |
| smf_calendar_holidays     |
| smf_categories            |
| smf_collapsed_categories  |
| smf_custom_fields         |
| smf_gallery_cat           |
| smf_gallery_comment       |
| smf_gallery_pic           |
| smf_gallery_report        |
| smf_group_moderators      |
| smf_hcb_reminders         |
| smf_links                 |
| smf_links_bans            |
| smf_links_categories      |
| smf_links_comments        |
| smf_log_actions           |
| smf_log_activity          |
| smf_log_banned            |
| smf_log_boards            |
| smf_log_comments          |
| smf_log_digest            |
| smf_log_errors            |
| smf_log_floodcontrol      |
| smf_log_group_requests    |
| smf_log_httpBL            |
| smf_log_karma             |
| smf_log_mark_read         |
| smf_log_member_notices    |
| smf_log_notify            |
| smf_log_online            |
| smf_log_packages          |
| smf_log_polls             |
| smf_log_reported          |
| smf_log_reported_comments |
| smf_log_scheduled_tasks   |
| smf_log_search_messages   |
| smf_log_search_results    |
| smf_log_search_subjects   |
| smf_log_search_topics     |
| smf_log_spider_hits       |
| smf_log_spider_stats      |
| smf_log_subscribed        |
| smf_log_topics            |
| smf_mail_queue            |
| smf_membergroups          |
| smf_members               |
| smf_message_icons         |
| smf_messages              |
| smf_moderators            |
| smf_openid_assoc          |
| smf_package_servers       |
| smf_permission_profiles   |
| smf_permissions           |
| smf_personal_messages     |
| smf_picture_comments      |
| smf_pm_recipients         |
| smf_pm_rules              |
| smf_poll_choices          |
| smf_polls                 |
| smf_profile_albums        |
| smf_profile_comments      |
| smf_profile_pictures      |
| smf_scheduled_tasks       |
| smf_sessions              |
| smf_settings              |
| smf_smileys               |
| smf_spiders               |
| smf_subscriptions         |
| smf_tags                  |
| smf_tags_log              |
| smf_themes                |
| smf_topics                |
+---------------------------+
80 rows in set (0.00 sec)

MariaDB [crystal]>

You can view details on the columns in a particular table by using DESCRIBE tablename where tablename is the name of the table.

MariaDB [crystal]> DESCRIBE smf_smileys;
+--------------+----------------------+------+-----+---------+----------------+
| Field        | Type                 | Null | Key | Default | Extra          |
+--------------+----------------------+------+-----+---------+----------------+
| id_smiley    | smallint(5) unsigned | NO   | PRI | NULL    | auto_increment |
| code         | varchar(30)          | NO   |     |         |                |
| filename     | varchar(48)          | NO   |     |         |                |
| description  | varchar(80)          | NO   |     |         |                |
| smiley_row   | tinyint(4) unsigned  | NO   |     | 0       |                |
| smiley_order | smallint(5) unsigned | NO   |     | 0       |                |
| hidden       | tinyint(4) unsigned  | NO   |     | 0       |                |
+--------------+----------------------+------+-----+---------+----------------+
7 rows in set (0.05 sec)

MariaDB [crystaltokyo]>

You can also use EXPLAIN tablename, since EXPLAIN and DESCRIBE are synonyms, but the DESCRIBE keyword is more often used to view information about a table's structure, whereas EXPLAIN is more often used to obtain a query execution plan, i.e., an explanation of how MySQL would execute a query.

References:

  1. Showing all MySQL databases or all tables in a database
    Date: July 27, 2014
    MoonPoint Support
  2. MySQL :: MySQL 5.0 Reference Manual :: 13.8.2 EXPLAIN Syntax
    MySQL :: Developer Zone

[/software/database/mysql] permanent link

Once You Know, You Newegg AliExpress by Alibaba.com

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo