관리 메뉴

moozi

haksa table 본문

TIS_2020/응용SW2020_1기

haksa table

moozi 2020. 4. 14. 10:23

-- table생성
create table student(
id char(7) primary key,
name varchar(10) not null,
dept varchar(20) not null
);

 

 

-- 데이터입력
insert into student values('1091011','김철수','컴퓨터시스템');
insert into student values('0792012','최고봉','멀티미디어');
insert into student values('0494013','이기자','컴퓨터공학');

select * from student;

create table books(
  no char(6) primary key, -- 책번호
  title varchar(50) not null, -- 책이름
  author varchar(50) not null -- 저자
);


insert into books values('000001','오라클기본','이황');
insert into books values('000002','자바정복','율곡');
insert into books values('000003','HTML5','강감찬');

 

select * from books;

 

-- 책대여
drop table bookRent;

drop table bookRent; 

create table bookRent
( no char(10) primary key, -- 대여번호
  id char(7) not null, -- 학번
  bookNo char(6) not null, -- 책번호
  rDate char(8) not null ,-- 대여일
  constraint fk_bookrent foreign key(id)
  references student(id)
);

 


insert into bookRent values('2017071304','0792012','000001','20170713');
insert into bookRent values('2017071305','0792012','000002','20170713');
insert into bookRent values('2017071306','0494013','000003','20170713');


commit;

-- 학번, 학생이름, 책이름, 대여일
select s.id, s.name, b.title, br.rDate
from student s, books b, bookRent br
where br.id=s.id
and br.bookNo=b.no;

 
select s.id, s.name, b.title, br.rDate
from student s, books b, bookRent br
where br.id=s.id and br.bookNo=b.no
and s.dept='컴퓨터공학'
order by b.no;

commit;

'TIS_2020 > 응용SW2020_1기' 카테고리의 다른 글

4/14 haksa  (0) 2020.04.14
4/14 bookRent  (0) 2020.04.14
4/13 haksa2  (0) 2020.04.13
04/13 haksa  (0) 2020.04.13
haksa  (0) 2020.03.30
Comments