Friday, March 30, 2012

Increase database size

I have a database that is over 45 GB and need to increase the size, can someone help me with the code to get it done?
ThanksFrom Books Online:

ALTER DATABASE database
{ ADD FILE < filespec > [ ,...n ] [ TO FILEGROUP filegroup_name ]
| ADD LOG FILE < filespec > [ ,...n ]
| REMOVE FILE logical_file_name
| ADD FILEGROUP filegroup_name
| REMOVE FILEGROUP filegroup_name
| MODIFY FILE < filespec >
| MODIFY NAME = new_dbname
| MODIFY FILEGROUP filegroup_name {filegroup_property | NAME = new_filegroup_name }
| SET < optionspec > [ ,...n ] [ WITH < termination > ]
| COLLATE < collation_name >
}

< filespec > ::=

( NAME = logical_file_name
[ , NEWNAME = new_logical_name ]
[ , FILENAME = 'os_file_name' ]
[ , SIZE = size ]
[ , MAXSIZE = { max_size | UNLIMITED } ]
[ , FILEGROWTH = growth_increment ] )|||Can you fill in a few blanks first? Normally a database will grow as needed, until it fills the available disk space. Is your database refusing to grow (a setting), or running out of free disk (meaning you need to start using a new drive for it to grow more)?

Another question is which part of your database is growing, the data or the log? It might be as simple as needing to do a log backup.

This question makes me leary... There are way too many ways to get into trouble if you don't understand this kind of problem!

-PatP|||The problem was that the log was NOT set to automatically grow. It's growth was restricted. The person that was in charge of the database before me realize the problem. I tell you it is a long process to becoming a GOOD DBA. God help me.

Lystra|||How long does the backup take?|||About 40 minutes, it about 33GB in size. That reminds me, when you backup a database are you suppose to get back log space? I thought you get it back when you use the with truncate_only.

Thanks|||How big are the ldf and mdf files on the server?

The ldf, once it's grown, will not shrink, unless you have autoshrink on, which is not a good idea.

It's also not just the backup, you have to dump the transaction logs. That will "empty out" the log, but leave the log at the size it has grown to...which is good in a well maintained databse because it figures it will grow to that size again, so you don't want to to incur the overhead of shrinking a growing all the time, which is overhead.

BUT, if it's not well maintained, you probably should dump the log, and use DBB SHRINKFILE or SHRINKDATABASE

Look them up in BOL

No comments:

Post a Comment