truncate ->this resets the entire table, is there a way via truncate to reset particular records/check conditions.
For ex: i want to reset all the data and keep last 30 days inside the table.
Thanks.
4 | The short answer is no: MySQL does not allow you to add a But the good news is that you can (somewhat) work around this limitation. Simple, safe, clean but slow solution using First of all, if the table is small enough, simply use the
The Unfortunately, this will be very slow if your table is large... and since you are considering using the So here's one way to solve your problem using the Simple, fast, but unsafe solution using
Unfortunately, this solution is a bit unsafe if other processes are inserting records in the table at the same time:
Unfortunately, it is not possible to lock the table and truncate it. But we can (somehow) work around thatlimitation using Half-simple, fast, safe but noisy solution using
This should be completely safe and quite fast. The only problem is that other processes will see table Disclaimer: I am not a MySQL expert, so these solutions might actually be crappy. The only guarantee I can offer is that they work fine for me. If some expert can comment on these solutions, I would be grateful. | ||
출처 : http://stackoverflow.com/questions/3704834/truncate-with-condition
[기초] 임시테이블 @Table 만들기 (0) | 2013.10.30 |
---|---|
[MSSQL] 문자열 이나 이진 데이터 는 잘립니다. (0) | 2013.10.07 |
테이블 복사 쿼리 (0) | 2013.09.25 |
저장 프로시저 만들었음. (1) | 2013.09.10 |
[펌] 프로시저 만들기 (0) | 2013.08.29 |