Delete OR Truncate

  • Hi Experts,

    I have a small doubt regarding the permission ALTER.

    By giving this we can truncate a table but we cant delete..Considering the security issues i think TRUNCATE is serious as its a no logged operation.

    My doubt is why sql allowing truncate in ALTER and not delete.

    Please Help

    TIA

  • Ratheesh.K.Nair (4/28/2010)


    Considering the security issues i think TRUNCATE is

    Truncate is minimally logged operation. Rows affected by truncate operations are not logged, however, the log contains info that a particular table was truncated.



    Pradeep Singh

  • Thanks Pradeep..

    Can you please let me know why like this?? I wonder why Truncate remove all data which cannot be rolled back with just an ALTER PERMISSION

    TIA

  • Check out this QOTD, also check out the discussion that follows, all your questions will be answered there :

    http://www.sqlservercentral.com/questions/T-SQL/69738/

    http://www.sqlservercentral.com/Forums/Topic908285-1198-1.aspx

  • Thanks Ninja,

    So TRUNCATE and DELETE are almost same then why its like TRUNCATE can be done by using an ALTER permission where as DELETE cannot and need specific permission?

  • I can't tell you specifically why truncate is allowed and not delete when you give the alter permission, but you're wrong about rollbacks. Truncate can be rolled back.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant Fritchey (4/28/2010)


    I can't tell you specifically why truncate is allowed and not delete when you give the alter permission, but you're wrong about rollbacks. Truncate can be rolled back.

    This could be attributed to granulity. Give the least amount of permissions to any user. You may need to be able to truncate a table to reload it from another environement. But without being allowed to delete 1 single row because you need to have both tables perfectly identical.

  • Truncate is generally more efiicient when clearing the whole table and unlike delete will reset any seed value as well!

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Ninja's_RGR'us (4/28/2010)


    Grant Fritchey (4/28/2010)


    I can't tell you specifically why truncate is allowed and not delete when you give the alter permission, but you're wrong about rollbacks. Truncate can be rolled back.

    This could be attributed to granulity. Give the least amount of permissions to any user. You may need to be able to truncate a table to reload it from another environement. But without being allowed to delete 1 single row because you need to have both tables perfectly identical.

    Yeah, it makes a sort of sense. It is much more of an administrative task, when looked at right, and much less about manipulating data. Partly because it's so complete.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thanks Everyone ..

    but wat abt data security..

  • Has nothing to do with truncate or delete... if the user shouldn't have access to the data, then don't grant it.

  • I am with Ninja

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply