Azavea.Open.DAO.SQL.SqlConnectionUtilities.TruncateTable C# (CSharp) Method

TruncateTable() public static method

Truncates a table if supported by the DB, otherwise deletes all rows (which is effectively the same, but potentially a lot slower).
public static TruncateTable ( AbstractSqlConnectionDescriptor connDesc, string tableName ) : void
connDesc AbstractSqlConnectionDescriptor The database connection descriptor. This is used both as /// a key for caching connections/commands as well as for /// getting the actual database connection the first time.
tableName string What table we want to blow away the contents of.
return void
        public static void TruncateTable(AbstractSqlConnectionDescriptor connDesc, string tableName)
        {
            StringBuilder sql = DbCaches.StringBuilders.Get();
            if (connDesc.SupportsTruncate())
            {
                sql.Append("TRUNCATE TABLE ");
            }
            else
            {
                sql.Append("DELETE FROM ");
            }
            sql.Append(tableName);
            XSafeCommand(connDesc, sql.ToString(), null);
            DbCaches.StringBuilders.Return(sql);
        }