Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: need sql query to check if a column is unique
On 28 Feb., 11:08, "samir...._at_googlemail.com"
<samir...._at_googlemail.com> wrote:
> Hey guys,
>
> I've an table with a column, let's call it employee_id. Do you know an
> sql statement, which can check employee_id, if it has duplicate
> entries ?
>
> regards Samir
select employee_id, count(*) from <table> group by employee_id having count(*) > 1;
How about a UNIQUE constraint ?
regards Received on Wed Feb 28 2007 - 04:36:50 CST