Unique-constraint is an index that sets one or multiple fields to be unique in a data entity
Questions tagged [unique-constraint]
1353 questions
-1
votes
2 answers
Unique ID Generation From DB value with 11 digits using Java causing Unique constraint exception
I have a requirement where we need to generate unqiue block ID which will be 11 characters.
We have below logic to generate it,
public String generateBlockId(){
boolean alreadyExists = true;
String newBlockId = "";
…

vasantharajan
- 265
- 5
- 18
-1
votes
1 answer
How to add a unique constraint such that one of my field in my table should checks the uniqueness only based on the another field in my table
My table name: Records
Fields:
School_id,
Admission_id
Association:
class Record < ActiveRecord::Base
belongs_to :school
For example
So i need to have a made an uniqueness such that admission id should be unique on school alone, different school…

jegan
- 31
- 7
-1
votes
1 answer
SQL Unique Constraint with columns spanning multiple tables
I have a scenario where i would need to add a unique constraint using columns from 2 different tables.
I have 2 tables. The first table is like,
TABLE MODEL(
ID PRIMARY_KEY,
KEY
)
and the second table as,
TABLE OWNERS(
ID PRIMARY_KEY,
…

Vamshi
- 11
- 4
-1
votes
2 answers
cannot set null to a unique column
so this is my table
CREATE TABLE "client" (
"id" INTEGER,
"name" TEXT COLLATE NOCASE,
"surname" TEXT COLLATE NOCASE,
"number" TEXT UNIQUE COLLATE NOCASE,
"car_brand" TEXT,
"modele" TEXT,
"phone_nbr" TEXT,
PRIMARY KEY("id"…

Taher ZRIBI
- 11
- 5
-1
votes
1 answer
SQL Server :: create an ERD from a database without constraints
I have a database that was given to us without constraints, no PK or FK.
I'm trying to reverse engineer to find out connections between tables. In order to do so my approach is to create a list of all columns with the same name and data type. So I…

Francesco Mantovani
- 10,216
- 13
- 73
- 113
-1
votes
3 answers
How to remove unique constraint in MySQL?
I was searching online about how to remove unique constraint in MySQL in the Internet and I found a lot of solutions.
DROP INDEX index_name ON table_name;
ALTER TABLE table_name
DROP INDEX index_name;
ALTER TABLE table_name
DROP CONSTRAINT…

Random Person
- 163
- 1
- 17
-1
votes
2 answers
Merge sql throws Unique constraint violation error
I have below two table for which when i query table TEST_RUA:
select CLASS, ID_LL, ID_UU, TKR from TEST_RUA where ID_UU= 'GV9999B12M0'
it returns:
CLASS ID_LL ID_UU TKR
Bond (null) GV9999B12M0 WIB
When i query table…

Symonds
- 184
- 1
- 2
- 15
-1
votes
2 answers
Unique table constraint
I have a table as follows:
CREATE TABLE `b` (
`b1` int(11) DEFAULT NULL,
`b2` int(11) DEFAULT NULL,
UNIQUE KEY `b1` (`b1`,`b2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Here, the unique table constraint is given for 2 fields. But, in the show…
user14151025
-1
votes
1 answer
Return inserted values from 'insert' query
I have simple table and I need to insert in to it values from array, but only values which are not exists in table and return from query inserted values, how I can do this?
I have next query, but it just inserts values:
INSERT INTO my_table(id,…

Ted
- 1,682
- 3
- 25
- 52
-1
votes
1 answer
How to avoid search Query OF @UniqueConstraint in JPA
I want to improve performance by not doing search query where i know that data will be unique.(In my app every new user will require default data. Which will be created in server side where there is no need to do unique test.)

Chand
- 3
- 2
-1
votes
1 answer
Nasty sql error(POSTGRES) "There is no unique constraint matching given keys for referenced table..."
EDIT: tables have been translated from my language to english i've changed te reference of foreign key in table Comment to "Utente" -> "User"
Hi everyone i'm trying to build a small review system in sql as follows. Every user can comment on some…

flatbrain
- 3
- 4
-1
votes
2 answers
Generating unique id for customer without using sequence while using multiple sessions in oracle
I am generating customer id using select nvl(max(customerid),0)+1. It's working, but per hour almost 700 to 1000 customers are onboarding. So while using above code at fraction of some milliseconds the session getting same max of customer id. So it…

Shagul
- 1
- 1
-1
votes
1 answer
Adding a UNIQUE key to a large existing MySQL table which is receiving INSERTs/DELETEs
I have a very large table (dozens of millions of rows) and a UNIQUE index needs to be added to a column on that table. I know for a fact that the table does contain duplicated values on that key, which I need to clean up (by deleting rows/resetting…

Julik
- 7,676
- 2
- 34
- 48
-1
votes
1 answer
Why composite of primary key with other (not null) columns not automatically unique in PostgreSQL?
When create two tables using the following queries in PostgreSQL:
create table test_unique_pk (
id serial primary key,
value varchar not null
);
create table refer_unique_pk (
id integer,
value varchar,
foreign key (id,…

xiang0x48
- 621
- 6
- 20
-1
votes
1 answer
UNIQUE Constraint PowerDesigner9
I am a beginner with PD.
I would like to know if it is possible to modelize the UNIQUE constraint in the models ?
Thanks for your help.

satcha
- 129
- 1
- 13