feat: 优化判断表是否存在的查询语句

This commit is contained in:
xuna 2022-11-15 21:53:54 +08:00
parent 16a36d3f53
commit 6b49034502
2 changed files with 2 additions and 2 deletions

View File

@ -212,7 +212,7 @@ where a.table_schema in ({0}) and a.table_name in ({1})", tboldname ?? tbname);
if (istmpatler == false)
{
var existsPrimary = LocalExecuteScalar(tbname[0], _commonUtils.FormatSql(" select 1 from information_schema.key_column_usage where table_schema={0} and table_name={1} and constraint_name = 'PRIMARY' limit 1", tbname));
var existsPrimary = LocalExecuteScalar(tbname[0], _commonUtils.FormatSql(" select 1 from information_schema.columns where table_schema={0} and table_name={1} and column_key = 'PRI' limit 1", tbname));
foreach (var tbcol in tb.ColumnsByPosition)
{
if (tbstruct.TryGetValue(tbcol.Attribute.Name, out var tbstructcol) ||

View File

@ -201,7 +201,7 @@ where a.table_schema in ({0}) and a.table_name in ({1})", tboldname ?? tbname);
if (istmpatler == false)
{
var existsPrimary = LocalExecuteScalar(tbname[0], _commonUtils.FormatSql(" select 1 from information_schema.key_column_usage where table_schema={0} and table_name={1} and constraint_name = 'PRIMARY' limit 1", tbname));
var existsPrimary = LocalExecuteScalar(tbname[0], _commonUtils.FormatSql(" select 1 from information_schema.columns where table_schema={0} and table_name={1} and column_key = 'PRI' limit 1", tbname));
foreach (var tbcol in tb.ColumnsByPosition)
{
var isIdentityChanged = tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1;