Questions tagged [unique-constraint]

Unique-constraint is an index that sets one or multiple fields to be unique in a data entity

1353 questions
-1
votes
2 answers

Moving T-SQL datatime column for X days overlapping UNIQUE constraint

The problem is to use DATEADD function on column with unique value constraint taking into consideration the fact that new values will overlap existing values and in fact there will be violation of constraint, because we can not have two rows with…
Przemek Marcinkiewicz
  • 1,267
  • 1
  • 19
  • 32
-1
votes
2 answers

SQL unique column based on other columns

I have a SQL Server database table that I am trying to fix without having to resort to using the front end code to determine if the name of the institute is unique. I am setting up a Linq to SQL code base for all of the inserts. here is the new…
mattgcon
  • 4,768
  • 19
  • 69
  • 117
-1
votes
1 answer

Unique constraint violated when I have a non-unique index

In my data warehouse I have table with unique key TABLE_UK on columns (ID,IDATE,NAME,GENERATION,O_ID,NODE_ID) and a non-unique index PER_INDEX on columns (ID,NAME,GENERATION,STRUCTURE_AREA,O_ID). While loading data from a source table I am receiving…
priya77
  • 175
  • 2
  • 10
  • 24
-1
votes
1 answer

ORACLE - Enable Unique constraint issue (same constraint name, multiple schemas)

I'm having an issue trying to re-enable a unique constraint. I try using this command: alter table TESTSCHEMA_1.TEST_TABLE1 enable constraint TEST_UNIQUE_CONSTRAINT1; The issue is that i have multiple schemas (say: TESTSCHEMA_1 to _5), and they all…
Roberto Arias
  • 133
  • 1
  • 8
-1
votes
1 answer

default keyword with unique default value in mssql

I want to add a Column to a table in my Database. As several data already exist in that particular table , MSSQL does not allow me to add a not Null field. So I can use a default keyword to solve this problem and run the below mentioned Query - …
-1
votes
1 answer

unique value in Oracle

I'm new to oracle and I am doing simple exercises to broaden my knowledge I think I did every step successfully besides one. The question was: Create a table called Bank, which include following fields: Bank_id which is a number and has length of 5…
-1
votes
3 answers

How do I know the current value is already stored in the database ? [with LINQ and best performance]

I have UserName Column in my table and its is unique I want have Linq Method that check current UserName is duplicate or not ? check UserName column in database and return boolean result BUT I need a linq method with best performance (maybe using…
Hamed F
  • 800
  • 3
  • 11
  • 23
-1
votes
1 answer

How create a table with condition that data shoudl be present in one of the column

I am creating a table in oracle. I have condition that data should be present at least one of columns and both columns cannot be empty. CREATE TABLE testaccount ( request VARCHAR2 (2048 BYTE) NOT NULL, response1 CLOB, response2 …
Patan
  • 17,073
  • 36
  • 124
  • 198
-1
votes
2 answers

SQL Server 2008 Unique Key Constraint

I have a table call test and have four fields. i have create composit unique key on the table for which i want my records to be unique. we are tracking the previous versions of records and marking all the old records isdeleted=1, But the Problem is,…
-1
votes
2 answers

How to get unique constraint names from SQL Server with C#

I have created a unique constraint in an SQL Server Database using the following statement: ALTER TABLE mytable ADD CONSTRAINT mytable_unique UNIQUE (uid) How can I get all unique constraint names programmatically with C# SQLConnection object?
Stefanos Kargas
  • 10,547
  • 22
  • 76
  • 101
-1
votes
1 answer

How to get the column name of the CANDIDATE Keys through jdbc?

I need to find candidate keys of a table. As for a column to be a candidate key, it must be (1) NOT NULL and (2) UNIQUE. So what I am doing is: for(i=1;i
-2
votes
2 answers

In SQLite3, how do I troubleshoot a "Error: UNIQUE constraint failed" from an "insert into select"?

When I get a Error: UNIQUE constraint failed, is there a way to see which value caused the unique constraint violation? I have evidence that other databases tell you this information (see the DETAIL line in the question), but after an hour+ of…
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
-2
votes
1 answer

SQlite3 multi-column UNIQUE INDEX not having expected effect

I have a unique constraint on one of my tables: CREATE UNIQUE INDEX `role_contextid_targetid_ownerid_type_endedat_unique` on `role` (`contextId`, `targetId`, `ownerId`, `type`, `endedAt`) You can see it is part of the db definition here: But for…
Seph Reed
  • 8,797
  • 11
  • 60
  • 125
-2
votes
2 answers

how do i drop constraint with sqlite3?

I try to drop a constraint if this one exists but i get an error, here is my code and below the error : return knex.schema.raw( ` ALTER TABLE users DROP CONSTRAINT IF EXISTS "users_customer_id_email_unique", DROP CONSTRAINT IF EXISTS…
Newon
  • 23
  • 4
-2
votes
3 answers

Does SQL have a condition like 'IS UNIQUE'?

Wherever I was looking for, I've never heard about that any SQL implementations would have an IS UNIQUE "command". Did I miss something? If I'm right, what is the reason? In other words, why I can't state in SQL that a certain command, such as…
Zoltán Schmidt
  • 1,286
  • 2
  • 28
  • 48
1 2 3
90
91