-- 迁移表1、备份数据SELECT * INTO {0}_{1} FROM {0}2、清空数据TRUNCATE TABLE {0}3、回填数据INSERT INTO {0} SELECT {2} FROM {0}_{1} WHERE {3}
如果表有外键,不适合采用此方法。
查询所有表的记录数 SQL 语句:
来自:https://www.cnblogs.com/dahuzizyd/archive/2004/07/19/25565.html
SELECT ‘Owner‘=CONVERT(CHAR(10),t.TABLE_SCHEMA), ‘Table Name‘=CONVERT(CHAR(25),t.TABLE_NAME), ‘Record Count‘=MAX(i.ROWS)FROM SYSINDEXES i, INFORMATION_SCHEMA.TABLES tWHERE t.TABLE_NAME = OBJECT_NAME(i.ID) AND t.TABLE_TYPE = ‘BASE TABLE‘GROUP BY t.TABLE_SCHEMA, t.TABLE_NAMEORDER BY MAX(i.ROWS) DESC