-- 1. school database를 생성하시오. create database school; -- 2. depart(학과) 테이블을 생성하시오. -- 학과ID(pk), 학과명 use school; create table depart( departId char(4) not null primary key, departName varchar(50) not null ); -- 3. student 테이블을 생성하시오. -- 학번(pk), 이름, 학과ID(fk) create table student( studentId char(8) not null primary key, studentName varchar(50) not null, departId char(4) not null, foreign key (departId) references depart(departId) ); -- 4. 2번에 다음과 같이 데이터를 입력하시오. -- 0001,컴퓨터공학과 -- 0002,전자공학과 insert into depart values('0001','컴퓨터공학과'); insert into depart values('0002','전자공학과'); -- 5. 3번에 다음과 같이 데이터를 입력하시오. -- 20150001,홍길동,0001 -- 20160010,이순신,0002 insert into student values('20150001','홍길동','0001'); insert into student values('20160010','이순신','0002'); -- 6. student테이블에서 성이 '홍'씨인 사람을 검색하시오. -- 힌트. like '홍%' 사용 select * from student where studentName like '홍%'; -- 7.다음 항목을 출력하시오.(조인) -- 학번, 이름, 학과명 select student.studentId, student.studentName, depart.departName from student join depart on student.departId=depart.departId; -- 8.학과수를 출력하시오. select count(*) from depart; -- 9.전자공학과 학생목록을 출력하시오. select * from student where departId='0002'; select student.* from student, depart where student.departId=depart.departId and depart.departName='전자공학과'; -- 10. 2016학번 학생들을 출력하시오. select * from student where studentId>='2016';