MySQLでテーブル名を検索する
MySQLでテーブル名を調べるために、検索したいときがあります。
そんなとき、以下のようにSHOW TABLESコマンド入力すると良いです。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| > mysql -h=xxx -u=username -p=**** dbname
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 290
Server version: 5.1.36-community MySQL Community Server (GPL)
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> SHOW TABLES like 'wp_%';
+-----------------------+
| Tables_in_bgcom (wp_%)|
+-----------------------+
| wp2_blog_off_comments |
| wp2_blog_off_links |
| wp2_blog_off_options |
| wp2_blog_off_postmeta |
| wp2_blog_off_posts |
| wp2_blog_off_term_relationships |
| wp2_blog_off_term_taxonomy |
| wp2_blog_off_terms |
| wp2_blog_off_usermeta |
| wp2_blog_off_users |
+-----------------------+
13 rows in set (0.01 sec)
mysql>
|
1行目は、ログインコマンドです。-h=xxx -u=username -p=**** dbname
xxx:mysqlのホスト名
username:ログインするユーザ名
****:ログインするユーザのパスワード
dbname:使用するデータベース名
9行目で、テーブル名の先頭に’wp_’があるものを検索し、表示させています。
この記事を読んだ人は、こんな記事も読んでいます。:
コメント