SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


transactional log


transactional log

Author
Message
litu deb
litu deb
Valued Member
Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)

Group: General Forum Members
Points: 72 Visits: 266
If i need to truncate/shrink the transaction log file :

can I use dbcc shrinkdatabase(' ',truncateonly) instead of using dbcc shrinkfile(2,truncateonly).earlier I was using the 2nd option dbcc shrinkfile but had to do full backup after this.

If i do use shrinkdatabase cmd i think no need to take full backup.is it safe to use 'dbcc shrinkdatabase' rather than using 'dbcc shrinkfile' .Please advice me.

Thanks,
Litu
free_mascot
free_mascot
SSCarpal Tunnel
SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)

Group: General Forum Members
Points: 4041 Visits: 2235
In my openion both command do the same thing one shrinkfile will shrink single file while shrinkdatabase will shrink the set of files in the database. Also after executing any shrink command no need to do the full backup but on saffer side you can do it.

Also shrink command won't do any blocking or hold locks(Might be temporarily it can). BUT SHRINK COMMAND IS RESOURCE CONSUMING AND CONSUMES RESOURCES (CPU - MEMORY) OF THE SERVER HENCE ADVISABLE TO EXECUTE ON THE OFF-PICK HOURS.

---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Steve Jones
Steve Jones
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: Administrators
Points: 63803 Visits: 19116
You do not want to shrink the database. It causes fragmentation and messes with the index efficiency. If you need to shrink the log, shrink those files only.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
GilaMonster
GilaMonster
SSC Guru
SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)

Group: General Forum Members
Points: 88609 Visits: 45284
Also note that truncating a log (removing inactive log entries) and shrinking the log (reducing the size on disk) are two separate things.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


litu deb
litu deb
Valued Member
Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)

Group: General Forum Members
Points: 72 Visits: 266
Thanks it is really helpful information for me.
I have one more query:

If i shrink the whole database how caome it is possible to
shrink the main database(except log file).

Thnks,
Litu
GilaMonster
GilaMonster
SSC Guru
SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)

Group: General Forum Members
Points: 88609 Visits: 45284
Are you asking how to shink the database and not the log? You'd do it by shrinking each of the data files individually.

Note Steve's warning above. You don't want to shrink the database down, unless there's a good reason. See this link, and also check out the two links at the bottom of that article

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


litu deb
litu deb
Valued Member
Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)

Group: General Forum Members
Points: 72 Visits: 266
I know how to shrink whole database and also individual file.

I would like to know if i shrink only the database what would be the impact
on database.how come it reduce the size of database.

Thnks,
Litu
GilaMonster
GilaMonster
SSC Guru
SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)

Group: General Forum Members
Points: 88609 Visits: 45284
litu deb (2/1/2008)
I know how to shrink whole database and also individual file.


DBCC shrink database to shrink the whole database. DBCC ShrinkFile to shrink individual files

I would like to know if i shrink only the database what would be the impact
on database.


See Steve's comments, see the blog post I linked to, and be sure to check the links at the end of that. (to Paul randal's blog and the storage engine team's blog) Between them, they cover all the issues quite nicely


how come it reduce the size of database.


It only reduces the size of the DB if there's unused space in the data or log files. Shrink releases that space to the OS, so the file size decreases.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


litu deb
litu deb
Valued Member
Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)

Group: General Forum Members
Points: 72 Visits: 266
I understand used and free space in database.but what do you mean by unused space in database.

thnks,
Litu Deb
GilaMonster
GilaMonster
SSC Guru
SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)

Group: General Forum Members
Points: 88609 Visits: 45284
Unused = free

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search