쿼리문

권주희·2023년 7월 14일
0

table

drop table 테이블명

휴지통 확인

show recyclebin;
아니면
select * from user_recyclebin;

✔️ 휴지통 비우기

purge recyclebin;

시간 확인

select systimestamp from dual;

테이블 상태 바꾸기

 alter  table dept enable row movement ;

테이블 일정 시간으로 복구하기

 flashback table dept to timestamp to_timestamp('23/07/18:14:10:27',
                                               'RR/MM/DD:HH24:MI:SS');

실행계획 확인

explain plan for
어쩌구

select * from table(dbms_xplan.display);

nvl (null 값대신)

nvl(컬럼명, o)
nvl(to_char(comm) , 'no comm')

➡️ 형태 맞춰주기

null 마지막에 오게 정렬

order by comm desc nulls last;

index 생성

create index emp_sal on emp(sal);

index 이름 바꾸기

alter index "바꾸기전" rename to emp_sal;

CONSTRAINT

✔️ 부모키(primary key) <-> 자식키(foreign key)
뭐가 연결되어 있는지 확인하는 쿼리

SELECT *
FROM ALL_CONSTRAINTS A
, ALL_CONS_COLUMNS B
WHERE A.TABLE_NAME = 'DEPT' -- 여기에 테이블명 대문자로 기입
AND A.OWNER = B.OWNER
AND A.CONSTRAINT_NAME = B.CONSTRAINT_NAME
ORDER BY B.POSITION;

✔️ primary key 제약 걸기 (있는 테이블에)

 alter table emp
 add constraint emp_empno_pk  primary key(empno);
profile
열씨미하자

0개의 댓글