简体   繁体   中英

Should I drop and re-create database to save space?

I have a Microsoft SQL Server instance Instance1 with a database called Maintenance , with a table called TempWorkOrder . I have another SQL Server instance Instance2 that has a database called MaintenanceR1 with a table called WorkOrder .

Instance2 is a linked database on Instance1 . I want to copy any changed or new records from Instance2.MaintenanceR1.WorkOrder to Instance1.Maintenance.TempWorkOrder every hour.

I thought about creating a job that deletes all of the records in Instance1.Maintenance.TempWorkOrder and repopulates it with Instance2.MaintenanceR1.WorkOrder every hour. I am afraid this approach will let the log file get out of control as far as size goes.

Would I be better off dropping the table and re-creating it to keep the log file size reasonable? The table contains about 30,000 rows of data.

30,000 rows really shouldnt cause anything to get out of control. If you are really worried about log size, you can truncate instead of delete and bulk load with minimal logging your insert into the table.

https://www.mssqltips.com/sqlservertip/1185/minimally-logging-bulk-load-inserts-into-sql-server/

https://docs.microsoft.com/en-us/sql/t-sql/statements/truncate-table-transact-sql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM