+ 2

SQL

Which command is used to remove the datas from the table but it retains the structure of the table .

27th Feb 2025, 2:48 PM
Bharathi
3 Respostas
+ 3
Ahh, a few days ago, I saw a thread discussing this topic, but unfortunately, I can’t find it in the search bar now. Yeah exactly that's TRUNCATE. TRUNCATE TABLE removes all the rows quickly, and it's usually faster because it doesn't log individual row deletions. It also resets identity columns, which DELETE doesn't do. Both commands leave the table structure intact, but TRUNCATE is more efficient for removing all data. (It cannot be used if you want to retain specific rows). One more thing, Don’t confuse it with DELETE (removes specific rows) or DROP (deletes the entire table, structure included).
27th Feb 2025, 3:30 PM
✧GHOST✧
✧GHOST✧ - avatar
+ 5
Bharathi You mean remove all data from a table but table should be there, then you can use TRUNCATE command. Just write, `TRUNCATE TABLE table_name;`
27th Feb 2025, 3:16 PM
Gulshan Mahawar
Gulshan Mahawar - avatar
+ 2
Thanks a lot for answering my questions !!!!
27th Feb 2025, 3:32 PM
Bharathi