• petertrast (3/3/2010)


    Christian Buettner-167247 (2/5/2010)


    I wonder why there is no DDL trigger available to capture this of event...

    Because it is a DML event, the structure of the table is not changing, just the data in it?

    By the way, Oracle documentation contains an explicit list of DDL statements: http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/statements_1001.htm#sthref2301. TRUNCATE is in that list. So, at least in Oracle it is not a DML event.

    Unfortunately, I didn't find the similar list for MSSQL. However, these two quotes from BOL implicitly say that TRUNCATE belongs to DDL:

    http://msdn.microsoft.com/en-us/library/ms177570.aspx

    TRUNCATE TABLE (Transact-SQL)

    Permissions

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

    The minimum permission required is ALTER on table_name. 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

    OK, who's that guy with db_ddladmin permissions? http://msdn.microsoft.com/en-us/library/ms189121.aspx

    Database-level role name: db_ddladmin

    Description: Members of the db_ddladmin fixed database role can run any Data Definition Language (DDL) command in a database.

    So, db_ddladmin can run any DDL command; db_ddladmin can run TRUNCATE TABLE. This means TRUNCATE is a DDL command, I believe 🙂