ざっくり MySQL 入門(1)

エクセルシートでいうと、
シートにあたるのが table、各列を field、各行(各要素)を record と呼ぶ。
以下実行したコマンド履歴。
create database blog_app;show databases;
use mysql;use test;grant all on blog_app.* to dbuser@localhost identified by "password";use blog_app;create table users( id int, name varchar(255), email varchar(255), password char(32) );show tables;drop table users;show tables;
use blog_app;
create table users(id int not null auto_increment primary key,email varchar(255) unique,score double,sex enum('male','female') default 'male',created datetime);show tables;desc users;drop table users;

create table users( id int not null auto_increment primary key, email varchar(255) unique, score double, sex enum('male','female') default 'male', created datetime );desc users;insert into users (email, score, created) values ('hoge@google.com', '22.2', '2012-11-11 11:11:11')
 insert into users (email, score, created) values ('hoge@google.com', '22.2', '2012-11-11 11:11:11'),('hoge2@google.com', '222.2', '2012-11-11 11:11:11'),('hoge3@google.com', '22.2', '2013-11-11 11:11:11')

select * from users;select email, score from users;select * from users \G
use blog_app;select * from users;select * from users where score < 100;select * from users where score = 222.2;select * from users where score != 222.2;select * from users where email = 'hoge@google.com';select * from users where created < '2012-12-11 11:11:11';select * from users where email like '%@google.com';select * from users where email like '____@google.com';select * from users where score between 0 and 100;select * from users where sex in ('male');select * from users where sex in ('female');select * from users where sex in ('female', 'male');select * from users where sex in ('female', 'male') and score < 100;select * from users where score < 100 or email like '%@google.com';

コメント

このブログの人気の投稿

Callback関数を知らん人がまず理解すべきことのまとめ。

C言語でBluetoothスタックを叩きたい人のBluetooth開発入門その1

C++プログラミング入門(1) // 倉庫番プログラムの実装