- データベースを選択する.
use twitteruser1;
Database changed
(-これからデータベースを作る人はこのコマンド
create database twitteruser1;)
- データベース内のテーブル一覧を表示する.
show tables;
+------------------------+ | Tables_in_twitteruser1 | +------------------------+ | goods | +------------------------+ 1 row in set (0.00 sec)
(- これからテーブルを作る人はこのコマンド
create table goods;)
- ’goods’というテーブルのカラム名を表示する.
show columns from goods;
+-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | name | varchar(20) | YES | | NULL | | | price | int(11) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 3 rows in set (0.00 sec)
- ’goods’というテーブル内に要素を代入する.
insert into goods(id,name,price) values(1,'kenta',300);
Query OK, 1 row affected (0.08 sec)
- ’goods’というテーブル内の要素をすべて確認する.
select * from goods;
+------+-------+-------+ | id | name | price | +------+-------+-------+ | 0 | taro | 100 | | 1 | kenta | 300 | | 3 | jin | 600 | +------+-------+-------+ 3 rows in set (0.00 sec)