/// <summary>
/// Truncates a table if supported by the DB, otherwise deletes all rows (which is
/// effectively the same, but potentially a lot slower).
/// </summary>
/// <param name="connDesc">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.</param>
/// <param name="tableName">What table we want to blow away the contents of.</param>
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);
}