unique-index

Unable to create index because of duplicate that doesn't exist?

旧时模样 提交于 2019-12-02 21:37:45
I'm getting an error running the following Transact-SQL command: CREATE UNIQUE NONCLUSTERED INDEX IX_TopicShortName ON DimMeasureTopic(TopicShortName) The error is: Msg 1505, Level 16, State 1, Line 1 The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.DimMeasureTopic' and the index name 'IX_TopicShortName'. The duplicate key value is (). When I run SELECT * FROM sys.indexes WHERE name = 'IX_TopicShortName' or SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DimMeasureTopic]') the IX_TopicShortName index does not display. So

MySQL unique index by multiple fields

。_饼干妹妹 提交于 2019-12-02 09:35:59
问题 We have a special kind of table in our DB that stores the history of its changes in itself. So called "self-archived" table: CREAT TABLE coverages ( id INT, # primary key, auto-increment subscriber_id INT, current CHAR, # - could be "C" or "H". record_version INT, # etc. ); It stores "coverages" of our subscribers. Field "current" indicates if this is a current/original record ("C") or history record ("H"). We could only have one current "C" coverage for the given subscriber, but we can't

Is there any way to make a UNIQUE index case insensitive in Mysql 5.1.x ?

有些话、适合烂在心里 提交于 2019-11-30 20:16:17
If so - What must change in this table ? CREATE TABLE contestants ( idContestants int(10) unsigned NOT NULL AUTO_INCREMENT, idEvent int(10) unsigned NOT NULL, ContestantName varchar(50) DEFAULT NULL, PRIMARY KEY (idContestants), UNIQUE KEY Index_UniqueName (idEvent,ContestantName), ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; If you mean case sensitive then: ALTER TABLE `contestants` CHANGE `ContestantName` `ContestantName` VARCHAR( 50 ) CHARACTER SET latin1 COLLATE latin1_bin NULL DEFAULT NULL If you mean case insensitive then: ALTER TABLE `contestants` CHANGE `ContestantName`

Is there any way to make a UNIQUE index case insensitive in Mysql 5.1.x ?

假如想象 提交于 2019-11-30 04:46:57
问题 If so - What must change in this table ? CREATE TABLE contestants ( idContestants int(10) unsigned NOT NULL AUTO_INCREMENT, idEvent int(10) unsigned NOT NULL, ContestantName varchar(50) DEFAULT NULL, PRIMARY KEY (idContestants), UNIQUE KEY Index_UniqueName (idEvent,ContestantName), ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; 回答1: If you mean case sensitive then: ALTER TABLE `contestants` CHANGE `ContestantName` `ContestantName` VARCHAR( 50 ) CHARACTER SET latin1 COLLATE latin1

Unique Constraint vs Unique Index

依然范特西╮ 提交于 2019-11-30 01:13:56
I’m interested in learning which technique developers prefer to use to enforce uniqueness in SQL Server: UNIQUE CONSTRAINT or UNIQUE INDEX. Given that there is little difference in the physical implementation of each, how do you decide which is best? Are there reasons other than performance to evaluate the best solution? Are there database management advantages to one or the other? This MSDN article comparing the two is for SQL Server 2000: http://msdn.microsoft.com/en-us/library/aa224827(SQL.80).aspx For most purposes, there's no difference - the constraint is implemented as an index under

Create a unique index on a non-unique column

痴心易碎 提交于 2019-11-29 23:50:39
问题 Not sure if this is possible in PostgreSQL 9.3+, but I'd like to create a unique index on a non-unique column. For a table like: CREATE TABLE data ( id SERIAL , day DATE , val NUMERIC ); CREATE INDEX data_day_val_idx ON data (day, val); I'd like to be able to [quickly] query only the distinct days. I know I can use data_day_val_idx to help perform the distinct search, but it seems this adds extra overhead if the number of distinct values is substantially less than the number of rows in the

Unique Constraint vs Unique Index

倖福魔咒の 提交于 2019-11-28 22:01:28
问题 I’m interested in learning which technique developers prefer to use to enforce uniqueness in SQL Server: UNIQUE CONSTRAINT or UNIQUE INDEX. Given that there is little difference in the physical implementation of each, how do you decide which is best? Are there reasons other than performance to evaluate the best solution? Are there database management advantages to one or the other? 回答1: This MSDN article comparing the two is for SQL Server 2000: http://msdn.microsoft.com/en-us/library

Unique index or unique key?

南楼画角 提交于 2019-11-28 19:07:48
What is the diffrence between a unique index and a unique key? Dustin Laine The unique piece is not where the difference lies. The index and key are not the same thing, and are not comparable. A key is a data column, or several columns, that are forced to be unique with a constraint, either primary key or explicitly defined unique constraint. Whereas an index is a structure for storing data location for faster retrieval. From the docs: Unique Index Creates a unique index on a table or view. A unique index is one in which no two rows are permitted to have the same index key value. A clustered

Failed because incorrect arithabort setting

孤人 提交于 2019-11-28 14:43:26
I created a unique index (case description should be unique if IsDelete != 1) CREATE UNIQUE NONCLUSTERED INDEX [UniqueCaseDescription] ON [tblCases] ([fldCaseDescription] ASC) WHERE [IsDeleted] = CAST(0 AS varbinary(1)) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] Then when I run the following procedure it throws 'UPDATE failed because the following SET options have incorrect settings: 'ARITHABORT'. Verify that SET options are correct for use with

how to set a column as unique indexer on Sqlite

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 05:19:30
I have 3 columns (_id, column1, column2) _id column has been set as autoincrement In database there are some duplicate records, so I want to prevent duplicate records with setting column1 as unique indexer. How do I set a column as unique indexer on sqlite? Or how do I prevent duplicate records? No magic, just SQL: create table yourtablename (_id integer primary key autoincrement, column1 text not null unique, column2 text); _id will not be duplicate in any way because it is primary key, column1 neither because it is unique. 来源: https://stackoverflow.com/questions/8544231/how-to-set-a-column