0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[mysql]ログイン~データ追加

Posted at

自分用メモ

まだサーバにmysql入れてないって方はこちら
[まだtable作成してないって方はこちら]
(http://qiita.com/a11649a/items/567debcefc9d0595ed2d)

まずはログインしてDBにたどり着く。

ログイン

shell
mysql -u ユーザ名 -p データベース名

目的のDBへ移動する。

mysql
use データベース名;

データ挿入する前に

tableの定義を確認しよう

mysql
desc テーブル名;

確認すること
・カラム名(=列名)
・NULL欄
 ※NULL欄がNOのカラムは、insert時(データ挿入時)に省略できないので注意!

データ挿入

上記で確認したカラム名(=列名)を参考にデータ挿入を行う

mysql
insert into テーブル名(
列1,列2,列3
)values(
値1,値2,値3
);

例はこんな感じ。

mysql
insert into tekitou(
number,user_name,age
)values(
1,'穂下山太郎',20
);

ちゃんと挿入できたか確認。

mysql
select * from テーブル名;

入ってたら成功!

最後に

忘れずにログアウトしよう

mysql
exit;

以上!

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?