LoginSignup
0
0

More than 5 years have passed since last update.

SQL初学者のコマンドの入り口

Posted at

MySQLにルートでログインしよう

sql -u root
mysql>

とりあえずいじって勉強するならrootで入る。

データベースを選択しよう

mysql> use testDB;

use データベース名で入力する。

テーブル一覧を見よう

mysql> show tables;

これで選択したデータベースのテーブル一覧が見れる。

テーブルの概要を見よう

mysql> desc table1

これでテーブルのカラムやタイプ等の一覧を表示できる。

データを選択しよう

mysql> select * from table1 where column1 = 1;

解説
select * フィールド名(カラム名)を全て選択している。
from table1テーブル名table1を選択する。
where column1 = 1条件としてカラム名column1の値が1のレコードを取得する。

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