SQL/Oracle
[Oracle] 오라클 user_tables 모든 테이블 일괄 삭제, 모든 시퀀스 삭제
http://portfolio.wonpaper.net
2024. 7. 29. 23:09
Select 'Drop TABLE "'|| TABLE_NAME ||'" CASCADE CONSTRAINTS;' From user_tables;
모든 테이블 삭제
1
2
3
4
5
|
BEGIN
FOR r IN (SELECT table_name FROM user_tables) LOOP
EXECUTE IMMEDIATE 'DROP TABLE ' || r.table_name || ' CASCADE CONSTRAINTS';
END LOOP;
END;
|
cs |
모든 인덱스 삭제
1
2
3
4
5
|
BEGIN
FOR r IN (SELECT index_name FROM user_indexes WHERE table_owner = 'ABC') LOOP
EXECUTE IMMEDIATE 'DROP INDEX ' || r.index_name;
END LOOP;
END;
|
cs |
모든 시퀀스 삭제
1
2
3
4
5
|
BEGIN
FOR r IN (SELECT sequence_name FROM user_sequences) LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE ' || r.sequence_name;
END LOOP;
END;
|
cs |
https://jack-of-all-trades.tistory.com/313