MySQLのSQL
プロジェクトで使用したMySQLのSQLの一覧
●データベースの作成
create database [データベース名] ;
●既存のデータベースを一覧表示
show databases ;
●データベースを削除
drop database [データベース名] ;
●使用するデータベースを選択
use [データベース名] ;
●データベースにテーブルを作成
create table [テーブル名] ( [列名] [列の型] , [列名] [列の型] ) ;
●既存のテーブルを一覧表示
show tables ;
●データベースからテーブルを削除
drop table [テーブル名] ;
●テーブルにデータを挿入
insert into [テーブル名] ( [列名] , [列名] ) values ( [値] , [値] ) ;
●テーブルのデータを更新
update [テーブル名] set [列名] = "[値]" where [行名] = "[値]" ;
●テーブルのデータを削除
delete from [テーブル名] where [行名] = "[値]" ;
●テーブルのカラムを追加
alter table [テーブル名] add [列名] [列の型] ;
●テーブルのデータを表示(検索)(全て)
select * from [データベース名] ;
●テーブルのデータを表示(検索)
select [列名] from [テーブル名] where [行名] = "[値]" ;
●テーブルのデータをソートして表示(検索)(全て)
select * from [データベース名] order by [行名] ;