2010. 3. 10. 09:21

SQL 명령어 뷰(view), 트랜잭션(Transaction) 구문

CREATE VIEW title_publishers AS (생성)

SELECT t.title, t.price, p.pub_name, p.city, p.state
FROM titles AS t INNER JOIN publishers AS p
ON t.pub_id = p.pub_id

SELECT * FROM title_publishers (사용)

ALTER VIEW title_publishers AS ... (수정)

DROP VIEW title_publishers (삭제)

begin tran
INSERT publishers VALEUS (1111, '미남출판사', '부산', '', '대한민국')
if @@error = 0
    commit tran
else
    rollback tran
set xact_abort on (여러 문장 중에 한 줄이라도 에러가 나면 취소)

begin tran
INSERT publishers VALUES (1111, '미남출판사', '부산', '', '대한민국')
UPDATE publishers SET pub_name = '신월서' WHERE pub_id = '0736'
if @@error = 0
    commit tran
else
    rollback tran