Thursday, September 28, 2017

Show and describe tables in MariaDB/MySQL Server

A. Connect to one single database

Each database in MySQL/MariaDB can consists of more than one table. If user want to access the content within a selected database. User must select a particular database in the server and inform the server that the user want to perform some operation on the selected database. The command to select the database is:
when a database is selected for operation in the MySQL / MariaDB console, the database name is indicated in the bracket [] before the ">" symbol to input the SQL. It is shown as the highlighted part of the text in Figure 1 below.
Figure 1: Select a particular database for operation in the MariaDB.
B. Show Tables

After selecting a database in the server, user can choose to view the list of tables content in the database. The command for viewing the list of tables is:
similar like the command "show databases", this command will show the entire list of tables in the selected database. The example output is shown in Figure 2 below.
Figure 2: Example output to show tables in a selected database.
C. Viewing The Metadata of a Table.

After knowing the table exist in a selected database, user can view the metadata of the table, which includes the column name, data type, primary key and etc. This will help user to understand the table and able to use the information in developing the information management system. The command to show the metadata of a table is:
The example output of the command is shown in Figure 3 below.
Figure 3: The output of describe command to show the metadata of table "help_topic" in database "mysql".