반응형
/****************************************************************************************************************
-- Title : [SQL2012] Make composite primary key on temp table
-- Key word : temptable temp table 임시테이블 임시 테이블 복합키 composite primary key pk
****************************************************************************************************************/
/*
-- when errors occur..
*/
-- Title : [SQL2012] Make composite primary key on temp table
-- Key word : temptable temp table 임시테이블 임시 테이블 복합키 composite primary key pk
****************************************************************************************************************/
/*
-- when errors occur..
*/
--// On 'A' session
CREATE TABLE #ttt
(
skey BIGINT not null
, fkey int not null
, rnum int
);
alter table #ttt
add constraint pk_tttttt primary key (skey, fkey);
/*
-- when error don't occur..
*/
--// Case 1.
--// Case 2.
--// On 'B' session
CREATE TABLE #ttt
(
skey BIGINT not null
, fkey int not null
, rnum int
);
alter table #ttt
add constraint pk_tttttt primary key (skey, fkey);
/* Errors occured!
메시지 2714, 수준 16, 상태 5, 줄 2
데이터베이스에 'pk_tttttt'(이)라는 개체가 이미 있습니다.
메시지 1750, 수준 16, 상태 0, 줄 2
제약 조건을 만들 수 없습니다. 이전 오류를 참조하십시오.
*//*
-- when error don't occur..
*/
--// Case 1.
CREATE TABLE #ttt
(
skey BIGINT not null
, fkey int not null
, rnum int
);
alter table #ttt
add primary key (skey, fkey);
CREATE TABLE #ttt
(
skey BIGINT not null
, fkey int not null
, rnum int
, primary key (skey, fkey)
, primary key (skey, fkey)
);
반응형