string sql_Rename_MainTable = string.Empty; // 改表名(主表->历史表)的sql
string sql_Create_MainTable = string.Empty; // 通过历史表的表结构创建主表的sql
switch (dbType)
{
case DbType.MySql:
sql_Rename_MainTable = "alter table '{0}' rename to '{1}'"; // alter table oldName rename to/as newName; 改表名(主表->历史表)的sql
sql_Create_MainTable = "create table '{0}' like '{1}'"; // create table newName like oldName;通过历史表的表结构创建主表的sql
break;
case DbType.SqlServer:
sql_Rename_MainTable = "EXEC sp_rename '{0}', '{1}'"; // exec sp_rename 'oldName', 'newName'; 改表名(主表->历史表)的sql
sql_Create_MainTable = "create table '{0}' like '{1}'"; // create table newName like oldName; 通过历史表的表结构创建主表的sql
break;
default:
// 略
break;
}
标签:rename,创建,sql,表名,MainTable,oldName,SQL,table,主表 From: https://www.cnblogs.com/qq2806933146xiaobai/p/17275803.html