drop table tbl_gogek purge;
create table tbl_gogek
(gogekId varchar2(30)
,email varchar2(50)
,gogekName varchar2(30) not null
,gogekPhone varchar2(30)
,constraint PK_tbl_gogek_gogekId primary key(gogekId)
);
desc tbl_gogek;
create table tbl_jumun
( gogekid varchar2(20)
, jepumCode varchar2(30)
, jumunDay date default sysdate
, jumunSu number(10)
, constraint PK_tbl_jumun primary key(gogekid, jepumCode, jumunDay)
);
insert into tbl_jumun(gogekId, jepumCode, jumunDay, jumunSu)
values('leess', '새우깡', default, 20);
insert into tbl_jumun(gogekId, jepumCode, jumunDay, jumunSu)
values('eomjh', '새우깡', default, 20);
insert into tbl_jumun(gogekId, jepumCode, jumunDay, jumunSu)
values('leess', '감자깡', default, 15);
insert into tbl_jumun(gogekId, jepumCode, jumunDay, jumunSu)
values('leess', '새우깡', default, 20);
commit;
select gogekid
, jepumcode
, to_char(jumunday, 'yyyy-mm-dd hh24:mi:ss') AS jumunday
, jumunsu
from tbl_jumun;
select *
from user_constraints
where table_name in('TBL_GOGEK','TBL_JUMUN');
alter table TBL_GOGEK
rename constraint SYS_C008386 to TBL_GOGEK_GOGEKID;
select *
from user_cons_columns
where table_name in('TBL_GOGEK','TBL_JUMUN');

select A.table_name, A.constraint_name, A.constraint_type, A.search_condition
, B.column_name, B.position
from user_constraints A join user_cons_columns B
ON A.constraint_name = B.constraint_name
where a.table_name in('TBL_GOGEK','TBL_JUMUN');
select A.table_name, A.constraint_name, A.constraint_type, A.search_condition
, B.column_name, B.position
from user_constraints A JOIN user_cons_columns B
ON A.constraint_name = B.constraint_name
where A.table_name in('TBL_GOGEK','TBL_JUMUN')
and A.constraint_type = 'P';
select A.table_name, A.constraint_name, A.constraint_type, A.search_condition
, B.column_name, B.position
from user_constraints A JOIN user_cons_columns B
ON A.constraint_name = B.constraint_name
where A.table_name = 'TBL_GOGEK'
and A.constraint_type = 'P';
제약조건은 항상 고유한 이름을 갖고 있으며 중복 불가