1
0

More than 5 years have passed since last update.

mysqlでテーブルに値を代入する.

Last updated at Posted at 2018-07-03
  • データベースを選択する.
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)
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0