Avatar billede puppetmaster Nybegynder
09. august 2005 - 10:02 Der er 3 kommentarer og
1 løsning

dbcc shrinkdatabase

Jeg følger et certification program på www.skillsoft.com og mener at have fundet en fejl i et af spørgsmålene, men vil gerne høre jeres mening.
Spørgsmålet:
******************************************************
As the SQL 2000 Server Administrator, you wish to free some unused space from the emp_rec database. The database is currently 200 MB, of which 120 MB is used for data storage. You determine that the database only requires an additional 30 MB. Which command should you use to reduce the size of the database to 150 MB?

The options are as follows

  DBCC SHRINKDATABASE (emp_rec, 25, TRUNCATEONLY) 
  DBCC SHRINKDATABASE (emp_rec, 15) 
  DBCC SHRINKFILE (emp_rec, 75) 
  DBCC SHRINKDATABASE (emp_rec, 25, NOTRUNCATE) 
  DBCC SHRINKDATABASE (emp_rec, 15, TRUNCATEONLY) 

******************************************************

Skillsoft mener at svaret er DBCC SHRINKDATABASE (emp_rec, 15), men beskrivelsen af DBCC SHRINKDATABASE på Microsoft's hjemmeside indikerer noget andet!!!

******************************************************
Syntax
DBCC SHRINKDATABASE
    ( database_name [ , target_percent ]
        [ , { NOTRUNCATE | TRUNCATEONLY } ]
    )

Arguments
database_name

Is the name of the database to be shrunk. Database names must conform to the rules for identifiers. For more information, see Using Identifiers. 

target_percent

Is the desired percentage of free space left in the database file after the database has been shrunk.

NOTRUNCATE

Causes the freed file space to be retained in the database files. If not specified, the freed file space is released to the operating system.

TRUNCATEONLY

Causes any unused space in the data files to be released to the operating system and shrinks the file to the last allocated extent, reducing the file size without moving any data. No attempt is made to relocate rows to unallocated pages. target_percent is ignored when TRUNCATEONLY is used.

Assume a database named mydb with two data files and two log files. Both data and log files are 10 MB in size. The first data file contains 6 MB of data.

For each file, SQL Server calculates a target size, which is the size to which the file is to be shrunk. When DBCC SHRINKDATABASE is specified with target_percent, SQL Server calculates target size to be the target_percent amount of space free in the file after shrinking. For example, if you specify a target_percent of 25 for shrinking mydb. SQL Server calculates the target size for this file to be 8 MB (6 MB of data plus 2 MB of free space). Therefore, SQL Server moves any data from the last 2 MB of the data file to any free space in the first 8 MB of the data file and then shrinks the file.
******************************************************

I følge Microsoft angiver target_percent hvor mange procent af den shrunkne fil der skal være space i forhold til dataene (6 MB data og 2 MB space), hvor i mod Skillsoft siger at der er procent af databasen FØR den shrinkes!

You should use the DBCC SHRINKDATABASE (emp_rec, 15) command. The value of the target_percent argument is determined by dividing the current database size from the amount of free space desired and by converting the answer to a percentage. Since you want 30 MB of free space from the current database of 200 MB, the target percent is 15%
Avatar billede rew Nybegynder
09. august 2005 - 14:05 #1
Nu ville man jo helst have at det var Microsoft som havde den rigtige ordlyd, men jeg har testet det lidt og er kommet frem til at det er Skillsoft's ordlyd som er mest rigtig. I realiteten er der ikke en særlig voldsom forskel i pladsforbrug på de to muligheder.
Avatar billede puppetmaster Nybegynder
09. august 2005 - 14:28 #2
Hmmm...er jeg gået galt et eller andet sted når jeg antager at størrelsen på databasen ville blive mindre med DBCC SHRINKDATABASE?! Der sker ikke en "%#!
Space available ændrer sig, med 1 MB, uanset om jeg angiver 1 eller 100% i shrinkage og uanset om jeg bruger TRUNCATEONLY parameteren. Sikke noget #%&¤! :(
Avatar billede rew Nybegynder
09. august 2005 - 14:33 #3
Det kan jeg ikke svare på, det virker fint hos mig.
Avatar billede puppetmaster Nybegynder
10. august 2005 - 09:14 #4
Nå, nu virker det også hos mig, kørte en anden DBCC procedure og kunne så shrinke databaserne. Tak.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Computerworld tilbyder specialiserede kurser i database-management

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester