################### # # # MySQL簡易manual # # # ################### 1.サーバ・クライアントの起動と停止 1-1.サーバの起動 % mysqld-max --standalone(win95&98) % mysqld-max-nt --standalone(win 2000&xp) 1-2.サーバの停止 % mysqladmin -u root shutdown バッチファイルの作り方 batという拡張子をつけたファイルに操作内容を書き込んで保存する ex: startsql.bat mysqld-max-nt --standalone 1-3.クライアントの起動 % mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.0.13-max-nt Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> と表示されれば成功です 1-4.クライアントの停止 mysql> quit 2.データベースの操作 2-1.データベースの作成 mysql> create database データベース名; 2-2.データベースの削除 mysql> drop database データベース名; 2-3.データベースの一覧参照 mysql> show databases; 2-4.データベースの選択 mysql> use データベース名; 3.テーブルの操作 3-1.テーブルの作成 mysql> create table テーブル名( フィールド名1 データ型, フィールド名2 データ型 ); ex: mysql> create table gimondata( id int , name verchar(20), gimon text, ); 3-2.テーブルの削除 mysql> drop table テーブル名; 4.データの操作 4-1.データの挿入 mysql> insert into テーブル名(フィールド名1,フィールド名2) values(データ1,データ2); ex: mysql>insert into gimondata values(1,'川勝名奈恵','データベースって何ですか'); 数値以外は''でくくりましょう 4-2.データの削除 mysql> delete from テーブル名 where 条件 ex: mysql> delete from gimondata where name='川勝名奈恵'; 4-3.データの更新 mysql> upadate テーブル名 set フィールド名 = 変更するデータ where 条件 ex: mysql> updata gimondata set gimon = 'JavaAPIって?' where id=2; 4-4.データの検索 4-4-1.テーブルの全データ検索 mysql> select * from テーブル名; 4-4-2.特定のフィールドの全データ検索 mysql> select フィールド名 from テーブル名 ex: mysql> select name from gimondata; 4-4-3.条件文付き検索 mysql> select フィールド名 from テーブル名 where 条件 ex: mysql> select gimon from gimondata where name='川勝名奈恵' ; +-------------------------------------+ | gimon | +-------------------------------------+ | データベースって何ですか | +-------------------------------------+ 1 row in set (0.11 sec) whereで条件をつなげていくとさらに絞込み検索ができます