In actual work and learning, many people's SQL Server 2005 database log files can be corrupted, such as hardware failures, computer restarts or shutdowns, and so on.
When the log file for SQL Server 2005 is corrupted, you will see the following:
1. Displaying the database in a suspect (suspect) state in
' Test2 '
UNION ALL
SELECT ' test3 '
UNION ALL SELECT '
test4 '
UNION ALL
Select ' TEST5 '
union ALL
Select ' Test6 '
UNION ALL
SELECT ' test7 '
UNION all
select ' Test8 '
select * from Testrestore
Check the results:
Then to do a delete operation, in order to locate when it happened, I added a waitfor command to make it happen at a certain time, so that when the recovery is accurate:
Use AdventureWorks
go
WAITFOR time ' 21:45 '
Now look at the data:
status of the database at this timeSelect Name,state,state_desc from sys.databases where name = ' TestDB 'Name State State_descTestDB 3 recovery_pending2. Setting the database to emergency modeALTER DATABASE TestDB SET EMERGENCYSelect Name,state,state_desc from sys.databases where name = ' TestDB 'Name State State_descTestDB 5 EMERGENCY3. Set the database to single-user modeALTER DATABASE testdb SET single_user with ROLLBACK IMMEDIATE4. Rebuilding the log
Tags: time detail Way NET write database backup ICA database management ATI in database management, database backup is very important. The Maintenance Plan Wizard makes it easy to complete a database backup. The following example shows how to implement a backup of a database with a backup strategy of One full backups per Sunday, differential daily backups (except Sunday), and hourly log backups. In addition, you can specify to delete outdated backu
Someone asked why SQL Server data has changed, but why is the best modification date of database files and log files not changed. In fact, this is a normal behavior.
The modification date of the SQL Server File is when the SQL Server closes the file Shutdown or the database is Detach, Offline) or the
Server
Method One:
--Let log no longer grow, but cannot compress logEXEC sp_dboption ' your_dbname ', ' trunc. Log ', ' TRUE '
Method Two:
--Super strong database file and log file compression,--After compression may cause the database to not be normal access, restart the database canDUMP TRANSACTION [database name] w
Tags: Database sql Server3. Configuration steps:Primary Server (A-machine) settings(1) Enable log Shipping ConfigurationRight-click the database for which you want to configure log transport->tasks-> ship Transaction logs...->enable this as a primary database in a log shippi
overhead is very large for a large OLTP transaction database in seconds.
In addition, database users are concerned with data changes, which are queried from the database application software, rather than through the WINDOWS file system. In addition, after the database is started, only SQL Server can exclusively update data files and log files, so there is no
I. Methods for deleting Database Log Files
When you run an SQL statement, the database reports that the transaction log is full and then reports an error. How to delete the database logs and try to delete the logs for half a day? Now we provide two ways to delete log files.
-- Create a Test Database Create Database DB
Go
-- Back up the database
Backup database dB to disk = 'C: \ dB. Bak' with format
Go
-- Create a test table
Create Table dB. DBO. tb_test (id int)
-- Delay 1 second, and then perform subsequent operations (this is because the SQL server has a time precision of up to 3% seconds. If there is no delay, the Restoration Operation to the time point may fail)
Waitfor delay '00: 00: 01'
Go
-- Assume that t
Because SQL2008 optimizes file and log management, the following commands can be run in SQL2000 and 2005, but SQL2008 does not support clearing logs by no_log.1. Clear logs The code is as follows:Copy code Dump transaction database name WITH NO_LOG 2. Truncate transaction logs: The code is as follows:Copy code Backup
Someone asked why SQL server data has changed, but why is the best modification date of database files and log files not changed. In fact, this is a normal behavior.
The modification date of the SQL Server File is when the SQL server closes the file (shutdown or the database is detach, offline) or the
SQL in use every query will generate a log, but if you do not go to clean up, it may be full of hard, the author encountered such a situation, the direct site backstage are not going to go. Let's learn how to clean this log together.
SQL2005 Empty Delete log:
Copy code code as follows:
Backup
Ms SQL database log Compression MethodMs SQL performance is very good, but the database has been used for a period of time, the database has become very large, the actual amount of data is not large. It is generally caused by database logs! The growth of database logs can reach several hundred MB.The cost of MSSQL virtual hosts on the Internet is also high. To av
Ms SQL database log Compression Method
Ms SQL performance is very good, but the database has been used for a period of time, the database has become very large, the actual amount of data is not large. It is generally caused by database logs! The growth of database logs can reach several hundred MB.
The cost of MSSQL virtual hosts on the Internet is also high.
--Create a test databaseCREATE DATABASE Db
Go
--Backing up the database
BACKUP DATABASE Db to disk= ' C:\db.bak ' with FORMAT
Go
--Create a test table
CREATE TABLE Db.dbo.TB_test (ID int)
--Delay 1 seconds, and then do the following (this is because SQL Server's time precision is 3% seconds, without delay, may cause restore to point in time the operation failed)
WAITFOR DELAY ' 00:00:01 '
Go
--Suppose we now mistakenly delete the Db.dbo.TB_test th
Using SQL Server2005 to empty a database can be implemented with the following SQL
Backup Log Dnname with no_log
Go
Dump TRANSACTION dnname with NO_LOG
Go
Use Dnname
DBCC Shrinkfile (2)
Go
However, this stored procedure has been canceled in SQL Server2008, and in 200
1. OverviewLOG Shipping The database backup process provided for SQL Server. It can replicate the entire database to another server. In this case, the transaction log is also periodically sent to the backup server for data recovery purposes, which keeps the server in a hot backup state and is updated as the data changes. It also provides monitoring servers (monit
Truncating the transaction log is a logical operation, just marking a portion of the log as ' no longer needed ' so you can reuse this space, truncation is not a physical operation, does not reduce the size of the file on disk,To reduce the physical size, you must shrink.-----------Sometimes a backup can not truncate the log:This is because the user opens a
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.