MariaDBでデータベース一覧とテーブル一覧を取得するコマンド

MariaDBで存在しているデータベースとテーブルの一覧が知りたい場合はshowコマンドを使って表示できるみたいです。

データベース一覧を表示

show databases;

テーブル一覧を表示

show tables from データベース名;

使い方は次のような感じです。

$ mysql -u username -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is ****
Server version: 10.2.2-MariaDB-valgrind-max-debug Source distribution

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 |
| mysql              |
| performance_schema |
| wordpress          |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> show tables from wordpress;
+----------------------------+
| Tables_in_MariaDB          |
+----------------------------+
| wp_commentmeta             |
| wp_comments                |
| wp_links                   |
| wp_options                 |
| wp_postmeta                |
| wp_posts                   |
| wp_term_relationships      |
| wp_term_taxonomy           |
| wp_termmeta                |
| wp_terms                   |
| wp_usermeta                |
| wp_users                   |
+----------------------------+
12 rows in set (0.00 sec)

リンク

SHOW DATABASES – MariaDB Knowledge Base
https://mariadb.com/kb/en/show-databases/

SHOW TABLES – MariaDB Knowledge Base
https://mariadb.com/kb/en/show-tables/

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です