| [サイトマップへ] |
SQLの基本機能を演習で理解するという内容です。
【実習内容】
.open C:\SQLite\mydb
create table P ( id integer primary key not null, name text, weight read );
drop table P;
.exit
【実習内容】
create table products ( id integer primary key not NULL, product_name text unique not NULL, type text not NULL, cost real, created_at datetime not NULL );
BEGIN TRANSACTION;
INSERT INTO products VALUES( 1, 'Fukuoka apple', 'apple', 50, datetime('now') );
INSERT INTO products VALUES( 2, 'Kumamoto orange L', 'orange', 30, datetime('now') );
INSERT INTO products VALUES( 3, 'Kumamoto orange M', 'orange', 20, datetime('now') );
INSERT INTO products VALUES( 4, 'Fukuoka melon', 'melon', NULL, datetime('now') );
COMMIT;
SELECT * FROM products; SELECT * FROM products WHERE type = 'orange'; SELECT * FROM products WHERE cost > 25;
【実習内容】
create table R (
A text,
B text );
begin transaction;
insert into R values('a','b');
insert into R values('d','a');
insert into R values('a','d');
commit;
create table S (
B text,
C text,
D text );
begin transaction;
insert into S values('b', 'c', 'f');
insert into S values('d', 'e', 'a');
insert into S values('d', 'e', 'c');
commit;
select * from R, S where R.B = S.B; select * from R, S where R.B = S.B and C = 'e'; select A, D from R, S where R.B = S.B;
(参考) CGI プログラムのサンプル
クリエイティブコモンズ BY NC SAです. 資料のご利用を歓迎します. ご利用についての詳細はこちらで案内しています。