SQL 2008 log Files account for 23G of hard disk space, and the transaction log has been truncated (Truncate), the actual log content is small, 1G is not, want to release the extra space occupied by the log files.
However, no matter how you shrink (Shrink) log files, space is not free and always error occurs:
cannot shrink
Starting from 10 Gb, oracle began to provide Shrink commands. If our tablespace supports automatic segment space management (ASSM), we can use this feature to narrow down the segment, that is, reduce the HWM. Here we need to emphasize that this new 10g feature is only valid for the ASSM tablespace, otherwise the ORA-10635: Invalid segment or tablespace type will be reported.
Here, we will discuss how to recycle wasted space for an ASSM segment.
Simila
In SQL SERVER 2008, BACKUP Log with TRUNCATE_ONLY is no longer supported, and to shrink the database log, you first need to truncate the file by setting the database recovery mode to simple.The statements are as follows:Use DATABASENAME;GO--Truncate The log by changing the database
Label:One, Check Database Integrity Task Check the allocation and structural integrity of the user and system tables, and indexes in the database, by running the D BCC CHECKDB Transact-SQL statement. Running DBCC ensures that any integrity problems with the database is reported, thereby allowing them to be addressed La
In general, the contraction of the SQL database does not greatly reduce the size of the database. Its main function is to shrink the log size. This operation should be performed on a regular basis to avoid excessive database logs.
1. Set
Copy Code code as follows:
DECLARE @name VARCHAR (25)
DECLARE @SQL VARCHAR (1000)
DECLARE @logid INT
DECLARE sysdatabase_name CURSOR for SELECT name from master.dbo.sysdatabases
OPEN Sysdatabase_name
FETCH NEXT from Sysdatabase_name into @name
While @ @FETCH_STATUS = 0
BEGIN
IF (@name not in (' xxx ')-database name that does not require log shrinkage
BEGIN
server|sqlserver| Data | Database with command line:
For database log files, such as: Database name: PUB; log file name Pub_log, currently 100M, to compress to 10M
First step: Truncate the transaction log
In SQL Query Analyzer, perform the backup LOG PUB with TRUNCATE_ONLY
Step two:
Server SQL Server 2000 will have log files because of the growing problem of time accumulation: The actual size of the database is 15M, the log file size is 625KB (the exported log file), but the log file actually occupies 200MB (the default setting is that the file log will grow automatically).
If you want to change the storage space of the current log file directly from the
page fill density was too low, 8 pages per zone, if one page is not empty, the shrinkfile command does not shrink the partition because the Shrinkfile command is in a zone, and it only shrinks A completely empty partition. So let's take a look at the fill density of the "hit" table, here we use the DBCC SHOWCONFIG (' TB ') command: It can be seen that although the utilization ratio of this table is lower, it is 25.76%[34:132], that is, the data th
Each file in the database can be reduced by removing unused pages. Although the database engine is effectively re-using space, shrinking a file becomes necessary after multiple occurrences of a file without the original size. Both the data and transaction log files can be reduced (shrunk). You can manually shrink the database
, status, you can observe the observation will be found, in fact, there are 0, 22 states, 0 is representative of idle, 2 for use. Never underestimate this state, which is important for shrinking a database log file. The reason that the log file can be shrunk is that the data at the end of the file is cleared so that the part of the space is freed, rather than escaping the tail to delete the contents of the header or the middle part of the file. The sh
ObjectiveOn a SharePoint server that has been running for more than 2 years, it is strange to find that Sharepoint_config's database files are getting bigger and larger and have reached 90 gigabytes, shrinking by 20 gigabytes, but recovering to 90 gigabytes of size a week later.Because of insufficient disk space, there are only 200GB size, there are a number of large and small sites to store photos, videos, documents, etc., so decided to study this pr
Tags: SQL Server--First query dbname_log in Sys.database_files name, here take xxx instead ofUse DBNameGOSELECT file_id, name from Sys.database_files;GO--the real contraction statement. SQL Server 2008 First changes the mode to Simple mode, then shrinks and then changes back to full mode.SE [Master]GOALTER DATABASE DBName SET RECOVERY simple with no_waitGOALTER
Tags: cannot record the way the research job log foreword file Sha ObjectiveOn the Sharepointserver, which has been implemented for more than 2 years, it is found that the Sharepoint_config database file is getting larger and bigger, has reached 90 GB, the contraction can reduce 20 GB, but will recover to 90 GB size after a week. is very strange.Because of insufficient disk space, there are only 200GB sizes. There are a number of large and small sites
Tags: run backup file management clears CTI Trunc set DBCC SQL2008 's shrink log due to SQL2008 's optimization of file and log management, the following statements can be run in SQL2005 but have been canceled in SQL2008: (SQL2005) Backuplog dnname withno_logGo
Dump TransactionDnname withno_logGo
UseDnnameDBCCShrinkfile (2)
Go
--------------------------------------------------------------
(SQL2008): In the SQL2008 to clear the log must be in simple m
Each file in the database can be reduced by deleting unused pages. Although the database engine will effectively reuse the space, it is necessary to shrink a file multiple times without the original size. Data and transaction log files can be reduced (shrunk ). You can manually contract database files in groups or sepa
file space is not reduced because the space is occupied. Note: The bulk-logged recovery model is consistent with the log processing method of the full recovery model. 1. Confirm the Recovery model The following is a recovery model that uses SQL Server Management Studio to check the database. 2. Full backup A full backup must be done before the log backup. Note: do not tick the "Copy backup only" opti
Delete duplicate records and save TABLE_NAME Records in #table_name
SELECT DISTINCT * INTO #table_name table_name
Delete from table_name
SELECT * INTO table_name from #table_name
drop table #table_name
Related to this is the "SELECT INTO" option, which can be used in database properties
dialog box, either hook up this item, or execute in Query Analyzer
Execute sp_dboption ' db_name ', ' SELECT INTO ', ' true '
Open. The default value is off.
*****
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.