SQLite 실습 예제
'2013년 겨울학기 > OCP장기집중교육과정' 카테고리의 다른 글
Movie DB - 1일째 실습 내용 (DB 생성 및 php) (0) | 2014.01.07 |
---|
Movie DB - 1일째 실습 내용 (DB 생성 및 php) (0) | 2014.01.07 |
---|
set names euckr;
create database if not exists moviedb
DEFAULT CHARACTER SET euckr collate euckr_korean_ci;
use moviedb;
create table if not exists user (
num int(11) NOT NULL AUTO_INCREMENT,
name varchar(40) NOT NULL,
userid varchar(40) NOT NULL,
passwd varchar(40) NOT NULL,
PRIMARY KEY(num)
) ENGINE=InnoDB default character set euckr collate euckr_korean_ci;
insert into user values (NULL, '홍길동', 'gdhong', '1234');
insert into user values (NULL, '임꺽정', 'gjlim', '1234');
insert into user values (NULL, '장동건', 'dgjang', '1234');
create table if not exists review (
reviewid int(11) NOT NULL AUTO_INCREMENT,
num int(11) NOT NULL,
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
title varchar(50) NOT NULL,
memo text DEFAULT NULL,
image varchar(100) DEFAULT NULL,
PRIMARY KEY(reviewid),
FOREIGN KEY(num) REFERENCES user(num)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB default character set euckr collate euckr_korean_ci;
insert into review values (NULL, 1, NULL, "변호인", "재밌어요~", "images/review1.jpg");
insert into review values (NULL, 1, NULL, "용의자", "재밌어요~~", "images/review2.jpg");
insert into review values (NULL, 2, NULL, "호빗 2", "재밌어요~~~", "images/review3.jpg");
select user.name, user.userid,
review.title, review.memo, review.time, review.image
from user,review
where title="변호인"
AND user.num = review.num;
select user.name, user.userid,
review.title, review.memo, review.time, review.image
from user,review
where user.num = review.num;
------------------------------
SQLite 실습 예제 (0) | 2014.01.08 |
---|