About 127,000 results
Open links in new tab
  1. sql - Difference between drop table and truncate table ... - Stack …

    Sep 25, 2008 · TRUNCATE TABLE is functionally identical to DELETE statement with no WHERE clause: both remove all rows in the table. But TRUNCATE TABLE is faster and uses fewer system and transaction log resources than DELETE. The DELETE statement removes rows one at a time and records an entry in the transaction log for each deleted row.

  2. What's the difference between TRUNCATE and DELETE in SQL

    Sep 26, 2008 · • Performance: TRUNCATE TABLE is faster and uses fewer system and transaction log resources. And one of the reason is locks used by either statements. The DELETE statement is executed using a row lock, each row in the table is locked for deletion. TRUNCATE TABLE always locks the table and page but not each row.

  3. sql - Truncate with condition - Stack Overflow

    Oct 3, 2010 · Unfortunately, it is not possible to lock the table and truncate it. But we can (somehow) work around that limitation using RENAME. Half-simple, fast, safe but noisy solution using TRUNCATE. 1. RENAME TABLE my_table TO my_table_work; 2. CREATE TABLE my_table_backup AS SELECT * FROM my_table_work WHERE …

  4. sql server - Permissions for truncating a table - Stack Overflow

    TRUNCATE TABLE permissions default to the table owner, members of the sysadmin fixed server role, and the db_owner and db_ddladmin fixed database roles, and are not transferable. However, you can incorporate the TRUNCATE TABLE statement within a module, such as a stored procedure, and grant appropriate permissions to the module using the ...

  5. Truncate/Clear table variable in SQL Server 2008

    Oct 5, 2021 · Of course a far easier alternative would be to switch to using a #temp table instead as that supports TRUNCATE directly. DML on both table variables and temp tables writes to the tempdb transaction log. Whether or not it is worth switching to TRUNCATE rather than DELETE depends on the size of data involved. TRUNCATE will just log the page ...

  6. sql server - Truncating Large Tables - Stack Overflow

    Oct 17, 2018 · TRUNCATE TABLE removes the data by deallocating the data pages used to store the table data and records only the page deallocations in the transaction log. Fewer locks are typically used. When the DELETE statement is executed using a row lock, each row in the table is locked for deletion. TRUNCATE TABLE always locks the table (including a ...

  7. Reset identity seed after deleting records in SQL Server

    The following details are taken from the MSDN page for TRUNCATE TABLE: Compared to the DELETE statement, TRUNCATE TABLE has the following advantages: Less transaction log space is used. The DELETE statement removes rows one at a time and records an entry in the transaction log for each deleted row.

  8. truncate table taking very long time, is it normal?

    Jul 20, 2013 · if truncate is slow i am thinking of creating a new table with same structure and then dropping the old one, i think that will be quite fast. pls share ur views on this. – smrati katiyar Commented Jul 20, 2013 at 12:58

  9. sql server - Fastest way to delete all the data in a large table ...

    TRUNCATE TABLE removes the data by deallocating the data pages used to store the table's data, and only the page deallocations are recorded in the transaction log. I just wanted to say that there is a fundamental difference between the two and because there is a difference, there will be applications where one or the other may be inappropriate.

  10. How to truncate a foreign key constrained table?

    If you are using PHPMYADMIN, it is very easy to truncate a table with foreign key constraint. Login to PHPMYADMIN and click the table you want to truncate. Then go to SQL tab Place your code to truncate the table in the SQL Editor example truncate table students; Replace students with the name of the table.

Refresh