473,473 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problems with unique key constraint.(CASE INSENSITIVE)

17 New Member
I'm stack with this problem with some time now.

Here is my problem.

CREATE TABLE category
(
catdb_id bigserial NOT NULL,
catdb_name character varying,
catdb_remarks character varying,
CONSTRAINT catdb_id_pk PRIMARY KEY (catdb_id)
)

INSERT INTO category(catdb_name) VALUES('DyCharleS')
---successfully inserted
INSERT INTO category(catdb_name) VALUES('dycharles')
---successfully inserted

How can i make this two values which i inserted above to be equal? Any solution. Thank you.
Sep 23 '07 #1
6 9530
amitpatel66
2,367 Recognized Expert Top Contributor
I'm stack with this problem with some time now.

Here is my problem.

CREATE TABLE category
(
catdb_id bigserial NOT NULL,
catdb_name character varying,
catdb_remarks character varying,
CONSTRAINT catdb_id_pk PRIMARY KEY (catdb_id)
)

INSERT INTO category(catdb_name) VALUES('DyCharleS')
---successfully inserted
INSERT INTO category(catdb_name) VALUES('dycharles')
---successfully inserted

How can i make this two values which i inserted above to be equal? Any solution. Thank you.
Convert the value to either UPPER or lower case everytime you do an insert because the data inserted in different case will not be the same
Sep 24 '07 #2
dycharles
17 New Member
Thanks for the reply.

I already do that. But i want to retain the original values or position that is being typed by the user. What will be my other solution? any suggestion? Thanks again.
Sep 24 '07 #3
rski
700 Recognized Expert Contributor
I'm stack with this problem with some time now.

Here is my problem.

CREATE TABLE category
(
catdb_id bigserial NOT NULL,
catdb_name character varying,
catdb_remarks character varying,
CONSTRAINT catdb_id_pk PRIMARY KEY (catdb_id)
)

INSERT INTO category(catdb_name) VALUES('DyCharleS')
---successfully inserted
INSERT INTO category(catdb_name) VALUES('dycharles')
---successfully inserted

How can i make this two values which i inserted above to be equal? Any solution. Thank you.

Creating index should be enough
CREATE UNIQUE INDEX in_category_cs ON category ((lower(catdb_name)))
Sep 24 '07 #4
dycharles
17 New Member
What if the user will insert this three value.
INSERT INTO category(catdb_name) VALUES('DyCharleS')
---successfully inserted
INSERT INTO category(catdb_name) VALUES('dycharles')
---successfully inserted
INSERT INTO category(catdb_name) VALUES('dyChaRleS')
---- successfully inserted

How can they be equal in unique constraint or in unique index? Thanks
Sep 24 '07 #5
rski
700 Recognized Expert Contributor
What if the user will insert this three value.
INSERT INTO category(catdb_name) VALUES('DyCharleS')
---successfully inserted
INSERT INTO category(catdb_name) VALUES('dycharles')
---successfully inserted
INSERT INTO category(catdb_name) VALUES('dyChaRleS')
---- successfully inserted

How can they be equal in unique constraint or in unique index? Thanks
They are equal because index is using the lower() function.
Sep 24 '07 #6
dycharles
17 New Member
Thanks, great help.

More Power
Sep 24 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
1
by: SM | last post by:
/* problem: Trying to get partitioned views to "prune" unneeded partitions from select statements against the partitioned view. There are 5 partitioned tables. Each with a check constraint...
5
by: Kamil | last post by:
Hello What should I use for better perfomance since unique constraint always use index ? Thanks Kamil
0
by: Christoph | last post by:
The query that I'm trying to execute is as follows: SELECT card_names.card_name, card_sets.set_name FROM card_names_in_sets, card_names, card_sets WHERE
8
by: Paul Reddin | last post by:
Hi, We have been having many issues with unique constraints and we seem to have boiled it down to the equivalent of the following very simple scenario... given a table with a unqiue...
5
by: aj | last post by:
DB2 WSE 8.1 FP5 Red Hat AS 2.1 What is the difference between adding a unique constraint like: ALTER TABLE <SCHEMA>.<TABLE> ADD CONSTRAINT CC1131378283225 UNIQUE ( <COL1>) ; and adding a...
3
by: Bruce Wood | last post by:
I know that this isn't a C# question, but I can't find a newsgroup specifically devoted to ADO.NET, other than a moribund one that deals with ADO in general. This problem is driving me to...
10
by: Laurence | last post by:
Hi there, How to differentiate between unique constraint and unique index? These are very similar but I cannot differentiate them? Could someone give me a hand? Thanks in advance
6
by: Alvin SIU | last post by:
Hi all, I have a table in Db2 v8 like this: Team Name Role ------ -------- --------------------- A Superman Leader A Batman Member A WonderWoman Member B ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.