SQLシェル

まず、シェルを起動。-p でパスワード入力をする。

$ mysql -p
Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 463 to server version: 5.0.20a-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

データベースを列挙する

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| mt                 |
| mysql              |
+--------------------+
8 rows in set (0.00 sec)

データベースを選択する

mysql> use mt;
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

テーブルを列挙する

mysql> show tables;
+-----------------+
| Tables_in_mt    |
+-----------------+
| mt_author       |
| mt_blog         |
| mt_category     |
| mt_comment      |
| mt_config       |
| mt_entry        |
| mt_fileinfo     |
| mt_ipbanlist    |
| mt_log          |
| mt_notification |
| mt_objecttag    |
| mt_permission   |
| mt_placement    |
| mt_plugindata   |
| mt_session      |
| mt_tag          |
| mt_tbping       |
| mt_template     |
| mt_templatemap  |
| mt_trackback    |
+-----------------+
20 rows in set (0.00 sec)

テーブルのフィールドを列挙する

mysql> show fields from mt_author;
+-----------------------------+--------------+------+-----+-------------------+----------------+
| Field                       | Type         | Null | Key | Default           | Extra          |
+-----------------------------+--------------+------+-----+-------------------+----------------+
| author_id                   | int(11)      | NO   | PRI |                   | auto_increment |
| author_api_password         | varchar(60)  | YES  |     |                   |                |
| author_can_create_blog      | tinyint(4)   | YES  |     |                   |                |
| author_can_view_log         | tinyint(4)   | YES  |     |                   |                |
| author_email                | varchar(75)  | YES  | MUL |                   |                |
| author_hint                 | varchar(75)  | YES  |     |                   |                |
| author_is_superuser         | tinyint(4)   | YES  |     |                   |                |
| author_name                 | varchar(50)  | NO   | MUL |                   |                |
| author_nickname             | varchar(50)  | YES  |     |                   |                |
| author_password             | varchar(60)  | NO   |     |                   |                |
| author_preferred_language   | varchar(50)  | YES  |     |                   |                |
| author_public_key           | mediumtext   | YES  |     |                   |                |
| author_remote_auth_token    | varchar(50)  | YES  |     |                   |                |
| author_remote_auth_username | varchar(50)  | YES  |     |                   |                |
| author_type                 | smallint(6)  | NO   | MUL | 0                 |                |
| author_url                  | varchar(255) | YES  |     |                   |                |
| author_created_on           | datetime     | YES  | MUL |                   |                |
| author_created_by           | int(11)      | YES  |     |                   |                |
| author_modified_on          | timestamp    | YES  |     | CURRENT_TIMESTAMP |                |
| author_modified_by          | int(11)      | YES  |     |                   |                |
| author_entry_prefs          | varchar(255) | YES  |     |                   |                |
+-----------------------------+--------------+------+-----+-------------------+----------------+
21 rows in set (0.73 sec)