Question: How do I truncate the transaction log without stopping the server or making a backup?
I just want to free up all the disk space it's using...
- there's no MobiLink or SQL Remote replication involved,
- I don't care about recovery,
- I don't even care about the data,
- but...
Answer: The dbbackup -xo parameter is what you want.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXUnBO95-YICdGTg80yWgR7uD52dJY6umL7wLggpibrOAFdQTEf_iwOxQyHn9jzqDqAAIyf5eYC-U-T2fLTaZPu0d30cMVNUEK6HR3lEST6BczyvBJ56rs78Pthi_YYtGgtz6eAvJ9bGY/s1600/Cecil+Beaton%252C+Queen+Elizabeth+II+in+Coronation+Robes%252C+June+1953+%2528c%2529+V%2526A+images.jpg)
Think of it like telling the Queen to skip the crown and throne stuff today, we just need you to clean the toilets.
Here's the story in pictures...
Before...
![Before](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaCLZEpIubhmdk76yNaBs7W5_86r_3m9_-fSmt7pxrjnvuO9fFtQGDnX8uSDpZToMGvrLKAX8pzQw-NbuhN8AhZyw3m2kS9vZMTDtiDJrz1z26z4v90L5YtrMAmgkAxhMwDNmyquw3Pmc/s1600/1+before+204_56.jpg)
during...
"%SQLANY12%\bin32\dbbackup.exe"^ -c "ENG=inventory;DBN=inventory;UID=dba;PWD=sql"^ -o c:\temp\dbbackup_log.txt^ -xo PAUSE
![dbbackup](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWNZuwv-h6UA4ynVPJmvvYx26lUzZNM5dhB2EEghFWdStEzsaIq967hCP84YLbHtazE4F5NQrFYU1BUSnhA919i9kmPzOx_9tj-le7YCswsau4N0XqhEl4Hx8GHtEgXDX81XE2QWpV2_E/s1600/2+Quick+669_194.jpg)
and after...
![After](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjetGTG7ACmqa_kiV8-KPjJrmcIb47t_J25tEmW67iM7HK12Te7iFM0THRPfUlcT_0e5D5i4z_bSvGWlxXMoMxJomC3ALnxYLwkjt0AZW77jwKUaJtxbt9vGY4c5Nl4NWwkjO98RYIwoMI/s1600/3+after+204_55.jpg)
Question from the audience: Why use a transaction log at all if you don't care about the recovery?
Answer: Because databases run faster with a transaction log. If there's no transaction log (dbinit -n), every COMMIT turns into a CHECKPOINT.
Question: Why use a database at all if you don't care about the data?
Answer::
It's like saying "Never use SELECT * !" because people get burned when they use it inappropriately... dbbackup -xo is the same, if you use it when you shouldn't, life will be hard.
6 comments:
In SQL, you can execute
BACKUP DATABASE DIRECTORY ''
TRANSACTION LOG ONLY
TRANSACTION LOG TRUNCATE;
http://dcx.sybase.com/index.html#1201/en/dbreference/backup-statement.html*d5e34394
The Queen was in Scotland last week and mentioned how she had enjoyed reading Breck's metaphor about log backups and said she had a little surprise for him in return: Surprise for Breck
Opps, for metaphor read simile! That's another for the chop (offence: misuse of the Queen's English).
@Pedant: Have things changed in Scotland? You now bow and scrape before the English Queen? :)
I thought she was all yours! The Queen of Canada
... but you're behind the times - even the SNP (Scottish National Party) has gone all monarchist these days. Monarchism - the new republicanism!
Five years later and still helpful. Thank you so much!
Post a Comment