osprey's diary

日々の雑感を書き綴ります

MariaDBでdatabase table の schema 情報の見方

備忘録。スキーマ情報の見方。

 

use <database_name> してから desc <table_name> すると情報が確認できる。

 

$ mysql -u root -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 5766

Server version: 5.5.52-MariaDB MariaDB Server

 

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

MariaDB [(none)]> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| owndb              |

| mysql              |

| performance_schema |

| test               |

+--------------------+

5 rows in set (0.00 sec)

 

MariaDB [(none)]> use owndb;

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 [owndb]> show tables;

+--------------------+

| Tables_in_owndb    |

+--------------------+

| mt_company         |

| mt_role            |

| mt_staff           |

| mt_user            |

 

+--------------------+

4 rows in set (0.00 sec)

MariaDB [owndb]> desc mt_company;

+-------------------+--------------+------+-----+---------+----------------+

| Field             | Type         | Null | Key | Default | Extra          |

+-------------------+--------------+------+-----+---------+----------------+

| id                | int(11)      | NO   | PRI | NULL    | auto_increment |

| ccode             | varchar(6)   | NO   | UNI | NULL    |                |

| cname             | varchar(60)  | NO   |     | NULL    |                |

| email             | varchar(255) | NO   |     | NULL    |                |

| fax               | int(11)      | YES  |     | NULL    |                |

+-------------------+--------------+------+-----+---------+----------------+

5 rows in set (0.01 sec)