반응형
DB2에서는 왜 Truncate 명령이 없는지 모르겠으나, 타 DB를 사용하던 사람들이라면 매우 불편하다.

Delete시에 로그를 줄이는 방법은 UOW 단위에서 activate not loggged initially 라는 명령어를 쓰면 되지만... 일일이 그 명령어를 쓸수 없는 경우 다음 명령어를 이용하여 간단하게 Truncate 기능을 수행 할 수 있다.

On Unix :

     db2 connect to <dbname>
     db2 import from /dev/null of del replace into <table-name>

On Windows:
 
     메모장으로 blank.txt 파일을 하나 만들면서 안에 아무런 내용도 써 넣지 않는다. 
     db2 connect to <dbname>
     db2 import from C:\blank.txt of del replace into <tablename> 
     또는 그냥 빈 파일을 생성하지 않고
     db2 import from NUL of del replace into <tablename> 

V9.7 에서는 그냥 truncate table ... immediate 명령어를 사용할 수 있다. 

추가적으로 ALTER TABLE NOT LOGGED INITIALLY WITH EMPTY 명령어를 이용해서도 Truncate 할 수 있다. 
반응형

+ Recent posts