독학으로 DB 연습 중인데 좀 어렵네요..
회사에서도 사용하면 좋을 것 같아서 공부 중인데
막히는 부분이 있어서 문의드립니다.
일단 기본적인 틀입니다.
USE mystore;
GO
CREATE TABLE customer
( cno char(10) NOT NULL,
cname char(20) NOT NULL,
city char(20) NOT NULL,
point int NOT NULL,
primary key (cno)
);
CREATE TABLE officetool
( fno char(10) NOT NULL,
fname char(20) NOT NULL,
price int NOT NULL,
quantity int NOT NULL,
city char(20) NOT NULL,
primary key (fno)
)
CREATE TABLE indent
( cno char(10) NOT NULL,
fno char(10) NOT NULL,
qty int NOT NULL,
odate datetime NOT NULL,
oprs char(20),
primary key (cno, fno, odate),
foreign key (cno) references customer,
foreign key (fno) references officetool
);
GO
INSERT INTO customer VALUES ('c1', '똘이', '서울', 20);
INSERT INTO customer VALUES ('c2', '철수', '인천', 15);
INSERT INTO customer VALUES ('c3', '유희', '인천', 30);
INSERT INTO customer VALUES ('c4', '수근', '대전', 20);
INSERT INTO customer VALUES ('c5', '성주', '대전', 23);
INSERT INTO officetool VALUES ('f1','연필', 100, 50, '서울');
INSERT INTO officetool VALUES ('f2','지우개', 200, 100, '인천');
INSERT INTO officetool VALUES ('f3','볼펜', 50, 150, '대전');
INSERT INTO officetool VALUES ('f4','A4용지', 250, 30, '서울');
INSERT INTO officetool VALUES ('f5','풀', 300, 20, '대전');
INSERT INTO officetool VALUES ('f6','칼', 150, 140, '서울');
INSERT INTO officetool VALUES ('f7','휴지', 400, 120, '인천');
INSERT INTO officetool VALUES ('f8','물티슈', 100, 40, '부산');
INSERT INTO indent VALUES ('c1', 'f1', 300, '2018-03-21', '용기');
INSERT INTO indent VALUES ('c1', 'f2', 200, '2018-04-04', '사랑');
INSERT INTO indent VALUES ('c1', 'f3', 400, '2018-04-19', '용기');
INSERT INTO indent VALUES ('c1', 'f4', 500, '2018-04-22', '사랑');
INSERT INTO indent VALUES ('c1', 'f5', 100, '2018-04-23', '매너');
INSERT INTO indent VALUES ('c1', 'f6', 100, '2018-04-27', NULL);
INSERT INTO indent VALUES ('c2', 'f1', 300, '2018-05-05', '사랑');
INSERT INTO indent VALUES ('c2', 'f2', 400, '2018-05-16', '매너');
INSERT INTO indent VALUES ('c3', 'f2', 200, '2018-05-18', NULL);
INSERT INTO indent VALUES ('c4', 'f2', 600, '2018-06-04', '사랑');
INSERT INTO indent VALUES ('c4', 'f4', 300, '2018-06-10', '매너');
INSERT INTO indent VALUES ('c4', 'f5', 400, '2018-06-18', '매너');
INSERT INTO indent VALUES ('c5', 'f7', 100, '2018-06-19', '용기');
INSERT INTO indent VALUES ('c5', 'f8', 100, '2018-06-20', '용기');
GO
요게 기본적인 틀입니다.
첫번째
"주문 수량(qty)이 40 이상 요청자(oprs)가 '사랑' 인 주문의 고객번호(cno), 용구명(fname), 주문일(odate)을 검색하는 질의"를 실행하는 'orders_received' 이름의 저장 프로시저를 만들려면 어떻게 해야되나요?
두번째
"서울"에 거주하는 고객의 포인트(point)를 2배로 증가 시켜서 DB에 저장된 내용을 update시키는 질의"를 실행하는 'double_point'이름의 저장 프로시저를 만든 후 정의문을 sp_helptext로 숨기게(볼 수 없게) 만들려면 어떻게 해야되나요?
create procedure usp_첫번째(
@qty int ,
@oprs varchar(20)
)
as
select *
from indent
where qty >= @qty
and oprs like @oprs ;
-----------------------------------------------
alter procedure double_point
WITH ENCRYPTION
as
,
,
,
,