Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Sybase > duplicate data violating clustered index ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-19-03, 10:22
jessicab jessicab is offline
Registered User
 
Join Date: Mar 2003
Posts: 3
Talking duplicate data violating clustered index ?

sybase 11.9.2

i have a table with a clustered index that nevertheless has allowed in a duplicate.

how on earth can this happen?

I've tested all of the combos i can think of on my v 12 server to try and recreate, but sybase blocks me from inserting (or updating) to a duplicate that violates the key no matter what order the index / data creation occurs.

any ideas??? thanks in advance.

jess.
Reply With Quote
  #2 (permalink)  
Old 03-19-03, 11:55
jessicab jessicab is offline
Registered User
 
Join Date: Mar 2003
Posts: 3
Re: duplicate data violating clustered index ?

if i create a clustered, composite index on fields 1 & 2 from a 3 field table i can insert duplicates of fields 1 & 2 provided 3 is different. if i try to insert a duplicate of all 3 fields (including the 3rd, non-indexed field) I get dup errors:

Attempt to insert duplicate row in table 'testuser' with index 'index_one' in
database 'data_sup2'. Could drop and recreate index with ignore duprow or allow
duprow.
Command has been aborted.

i would expect not to be able to create a duplicate of fields 1 & 2 regardless of what i'm doing with field 3 because a clustered index is unique by default. is there something wrong with my assumptions?


thank u
Reply With Quote
  #3 (permalink)  
Old 03-19-03, 13:22
MattR MattR is offline
Registered User
 
Join Date: Mar 2001
Location: Lexington, KY
Posts: 606
A clustered index does not enforce uniqueness unless you specify the keyword UNIQUE.

CREATE CLUSTERED INDEX bob ON foo( bar )
is not the same as
CREATE UNIQUE CLUSTERED INDEX bob on foo( bar )

You may be thinking of a PRIMARY KEY constraint in a CREATE TABLE statement. In this example:
CREATE TABLE foo ( bar PRIMARY KEY )

ASE will create a UNIQUE, CLUSTERED index on bar.
__________________
Thanks,

Matt
Reply With Quote
  #4 (permalink)  
Old 02-16-04, 17:29
Andy2004 Andy2004 is offline
Registered User
 
Join Date: Jan 2004
Posts: 19
Jess,
By default clustered index is not unique till you explicitly specify it(as already mentioned by Matt).But the problem which you are facing for the table testuser is because in a nonunique clustered index(which is default and which i guess you have created) sybase will allow duplicate keys but will not allow duplicate rows(unless you have specified allow_dup_row option).
Cheers,
Andy
Reply With Quote
  #5 (permalink)  
Old 02-24-04, 20:14
pg_vinod pg_vinod is offline
Registered User
 
Join Date: Feb 2004
Location: presently CS.USA
Posts: 1
Thumbs up Re: duplicate data violating clustered index ?

Clustered Index will physically sort the data.
If you want uniqueness of data with Clustered Index then you should create Clustered Index with unique option explicitly.
Otherwise it will accept duplicate records and sort then in order.

Other option to follow the normalization standard i.e., use of primary key (which in turn doest allow duplicate records)

I hope its clear to you.

P.G.Vinod
Sybase DBA


Quote:
Originally posted by jessicab
sybase 11.9.2

i have a table with a clustered index that nevertheless has allowed in a duplicate.

how on earth can this happen?

I've tested all of the combos i can think of on my v 12 server to try and recreate, but sybase blocks me from inserting (or updating) to a duplicate that violates the key no matter what order the index / data creation occurs.

any ideas??? thanks in advance.

jess.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On