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 3 years have passed since last update.

MySQLのDB確認・作成コマンド【一覧】

Posted at

mysqlに関するコマンドを毎度のこと調べてたので、『mysqlならここからコピペや!!』って感じで、自分用に見やすくまとめてみました。
要するに“コピペ用”です😎

MySQL接続コマンド

🟩 MySQLのサービスに入る
mysql -u root -p

🟩 入れなかった場合

//mysqlの起動
sudo service mysqld start

//MySQLの再起動
sudo service mysqld restart

//MySQLの確認
sudo service mysqld status

//MySQLの停止
sudo service mysqld stop

MySQLデータベースの作成 ・ 削除

🟧 データベースの作成と削除
//データベースの作成
create database データベース名;

//データベースの削除
drop database データベース名;

🟧 その他の作成と削除

//テーブルの作成
create table テーブル名(カラム名 データ型, カラム名 データ型);

//テーブルの削除
drop from テーブル名;

//データの削除
delete from テーブル名;

(注意)
ハイフン( - )が入るものは作れない。
アンダーバー( _ )ならOK。

MySQLデータベース確認

🟦 データベース名一覧表示(テーブルも同様)
show databases;

🟦 現在のデータベース表示

select database();

🟦 データベース内のテーブル一覧表示

show tables from データベース名;

🟦 データベース内のカラム一覧表示

show columns from テーブル名 from データベース名;

MySQL格納データ確認

🟫 データベースに接続する
use データベース名;

🟫 格納データを表示する

select * from テーブル名;

自分用にまとめたものですが、何かの役に立てば幸いです!😆
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?