Evenementer
Mar 31, 11 PM - Apr 2, 11 PM
Dat gréisst Léier-Evenement fir SQL, Fabric a Power BI. 31. Mäerz - 2. Abrëll. Benotzt de Code FABINSIDER, fir $400 ze spueren.
Mellt Iech haut unDëse Browser gëtt net méi ënnerstëtzt.
Upgrat op Microsoft Edge fir vun de Virdeeler vun leschten Eegeschaften, Sécherheetsupdaten, an techneschem Support ze profitéieren.
Applies to:
SQL Server
For a database under the full recovery model, all row-insert operations that are performed by bulk import are fully logged in the transaction log. Large data imports can cause the transaction log to fill rapidly if the full recovery model is used. In contrast, under the simple recovery model or bulk-logged recovery model, minimal logging of bulk-import operations reduces the possibility that a bulk-import operation fills the log space. Minimal logging is also more efficient than full logging.
Notiz
The bulk-logged recovery model is designed to temporarily replace the full recovery model during large bulk operations.
Minimal logging requires that the target table meets the following conditions:
The table isn't being replicated.
Table locking is specified (using TABLOCK).
Notiz
Although data insertions are not logged in the transaction log during a minimally logged bulk-import operation, the Database Engine still logs extent allocations each time a new extent is allocated to the table.
The table isn't a memory-optimized table.
Whether minimal logging can occur for a table also depends on whether the table is indexed and, if so, whether the table is empty:
If the table has no indexes, data pages are minimally logged.
If the table has no clustered index but has one or more nonclustered indexes, data pages are always minimally logged. How index pages are logged, however, depends on whether the table is empty:
If the table is empty, index pages are minimally logged. If you start with an empty table and bulk import the data in multiple batches, both index and data pages are minimally logged for the first batch, but beginning with the second batch, only data pages are minimally logged.
If the table is non-empty, index pages are fully logged.
If one of the indexes has IGNORE_DUP_KEY = ON, index and data pages are fully logged.
If the table has a clustered index and is empty, both data and index pages are minimally logged. In contrast, if a table has a B-tree based clustered index and is non-empty, data pages and index pages are both fully logged regardless of the recovery model. If you start with an empty rowstore table and bulk import the data in batches, both index and data pages are minimally logged for the first batch, but from the second batch onwards, only data pages are bulk logged.
Notiz
Documentation uses the term B-tree generally in reference to indexes. In rowstore indexes, the Database Engine implements a B+ tree. This does not apply to columnstore indexes or indexes on memory-optimized tables. For more information, see the SQL Server and Azure SQL index architecture and design guide.
For information about logging for a clustered columnstore index (CCI), see Columnstore index data loading guidance.
Notiz
When transactional replication is enabled, BULK INSERT operations are fully logged even under the bulk logged recovery model.
Evenementer
Mar 31, 11 PM - Apr 2, 11 PM
Dat gréisst Léier-Evenement fir SQL, Fabric a Power BI. 31. Mäerz - 2. Abrëll. Benotzt de Code FABINSIDER, fir $400 ze spueren.
Mellt Iech haut unTraining
Modul
Understand write-ahead logging - Training
Azure Database for PostgreSQL is an ACID compliant database service. Write-ahead logging ensures changes are both atomic and durable (the A and D in ACID). Changes are first written to the log before they're committed to the database. In this module, you learn how Azure Database for PostgreSQL implements write-ahead logging, and how the log can be used for replication and logical decoding.
Dokumentatioun
Keep identity values when bulk importing data - SQL Server
When you bulk import data that contains identity values to a SQL Server instance, by default, it assigns new values. You can choose to keep the original values.
BULK INSERT (Transact-SQL) - SQL Server
Transact-SQL reference for the BULK INSERT statement.
sp_tableoption (Transact-SQL) - SQL Server
sp_tableoption sets option values for user-defined tables.
Managing Bulk Copy Batch Sizes - SQL Server
Learn how the batch size for a bulk copy defines the scope of a transaction, which effects error behavior and locking overhead in SQL Server Native Client ODBC.