public override string RenameIndexQuery(NoDbTable table, NoDbIndex oldIndex, NoDbIndex newIndex) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("EXEC sp_rename N'{0}.{1}', N'{2}', 'INDEX';", table.Detail.GetTableDbName(), oldIndex.Name, newIndex.Name); return(stringBuilder.ToString()); }
public override string CreateIndexQuery(NoDbTable table, NoDbIndex index) { string schema = GetSchema(table); StringBuilder stringBuilder = new StringBuilder(); if (index.IsPrimaryKey) { stringBuilder.AppendFormat("ALTER TABLE {3}.{1} ADD CONSTRAINT {0} PRIMARY KEY ({2});", Escape(index.Name), Escape(table.Detail.GetTableDbName()), string.Join(", ", index.Columns.Select(x => Escape(x.ColumnName))), schema ); } else { stringBuilder.AppendFormat("CREATE {3} INDEX {0} ON {4}.{1} ({2});", Escape(index.Name), Escape(table.Detail.GetTableDbName()), string.Join(", ", index.Columns.Select(x => Escape(x.ColumnName) + " " + x.Sort)), (index.IsUnique ? "UNIQUE" : ""), schema ); } return(stringBuilder.ToString()); }
public override string RenameIndexQuery(NoDbTable table, NoDbIndex oldIndex, NoDbIndex newIndex) { string schema = GetSchema(table); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("ALTER INDEX {2}.{0} RENAME TO {1};", Escape(oldIndex.Name), Escape(newIndex.Name), schema); return(stringBuilder.ToString()); }
public override string DropIndexQuery(NoDbTable table, NoDbIndex index) { string schema = GetSchema(table); StringBuilder stringBuilder = new StringBuilder(); if (index.IsPrimaryKey) { stringBuilder.AppendFormat("ALTER TABLE {2}.{0} DROP CONSTRAINT {1};", Escape(table.Detail.GetTableDbName()), Escape(index.Name), schema); } else { stringBuilder.AppendFormat("DROP INDEX {1}.{0};", Escape(index.Name), schema); } return(stringBuilder.ToString()); }
public abstract string RenameIndexQuery(NoDbTable table, NoDbIndex oldIndex, NoDbIndex newIndex);
public abstract string DropIndexQuery(NoDbTable table, NoDbIndex index);
public abstract string CreateIndexQuery(NoDbTable table, NoDbIndex index);