February 5, 2008 at 8:22 am
Hi Guys,
I need a good way to check uniqueness of data in a specific table.
For instance, if i have a table 1,2,3,4,5
How do I make sure that 1 appears only once in this table?
Thanks,
February 5, 2008 at 8:48 am
anyone??
February 5, 2008 at 8:52 am
I have no idea what you mean.
Do you have 5 tables named "1", "2", "3", "4" and "5"?
Do you have 1 table with 5 columns named "1", "2", "3", "4" and "5"?
Do you have 1 table with 1 column and 1 record with value "12345"?
Do you have 1 table with 1 column and 5 record with values "1", "2", "3", "4" and "5"?
N 56°04'39.16"
E 12°55'05.25"
February 5, 2008 at 8:53 am
Try to add a UNIQUE index or an UNIQUE constraint.
N 56°04'39.16"
E 12°55'05.25"
February 5, 2008 at 8:54 am
You could create a UNIQUE index on the column and be sure it does not allow nulls. If there are duplicates you would get a message and the create index would fail.
Spotting duplicates can be also done via query.
select col1 from table
group by col1
having count(col1) > 1
Toni
February 5, 2008 at 9:17 am
Thanks a lot you guys =)
February 7, 2008 at 6:01 pm
Hi,
You can use UNIQUE constraints to make sure that no duplicate values are entered in specific columns that do not participate in a primary key. Although both a UNIQUE constraint and a PRIMARY KEY constraint enforce uniqueness, use a UNIQUE constraint instead of a PRIMARY KEY constraint when you want to enforce the uniqueness of a column, or combination of columns, that is not the primary key.
Multiple UNIQUE constraints can be defined on a table, whereas only one PRIMARY KEY constraint can be defined on a table.
Also, unlike PRIMARY KEY constraints, UNIQUE constraints allow for the value NULL. However, as with any value participating in a UNIQUE constraint, only one null value is allowed per column.
Thanks -- Vj
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply