Home » SQL & PL/SQL » SQL & PL/SQL » unique field
unique field [message #351686] Thu, 02 October 2008 08:09 Go to next message
mhakimjavadi
Messages: 37
Registered: July 2008
Member
Hi,

Could you please tell me, is a any query that I can find out the field is the unique field in table or not. It would be really appreciate it.

Thanks
Re: unique field [message #351688 is a reply to message #351686] Thu, 02 October 2008 08:13 Go to previous messageGo to next message
joy_division
Messages: 4644
Registered: February 2005
Location: East Coast USA
Senior Member
Please rephrase the question. I cannot tell what you are asking.

- Do a group of the column having count greater than 1
- A table cannot have two columns of the same name
- look at user_constraints or user_indexes

One of these should answer your question, but it is unclear.

[edit] added the last choice

[Updated on: Thu, 02 October 2008 08:14]

Report message to a moderator

Re: unique field [message #351690 is a reply to message #351686] Thu, 02 October 2008 08:18 Go to previous messageGo to next message
mhakimjavadi
Messages: 37
Registered: July 2008
Member
Hi,

Yes this is my answer.

‘Do a group of the column having count greater than 1’

But I need you explain more about it or if possible a sample.

Thanks
Re: unique field [message #351692 is a reply to message #351690] Thu, 02 October 2008 08:57 Go to previous messageGo to next message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
@mhakimjavadi,
mhakimjavadi wrote on Thu, 02 October 2008 18:48

But I need you explain more about it or if possible a sample.


Try to go through the following links if you are not familiar with GROUP BY Clause, HAVING Clause and COUNT Function

GROUP BY Clause
HAVING Clause
COUNT Function


The logic and clue have been already supplied by @joydivision. Try to go through the links and try implementing the logic supplied in your queries.

“Anyone can give up, it's the easiest thing in the world to do"

Regards,
Jo

[Updated on: Thu, 02 October 2008 08:58]

Report message to a moderator

Re: unique field [message #352468 is a reply to message #351686] Tue, 07 October 2008 21:32 Go to previous messageGo to next message
prt1979
Messages: 3
Registered: October 2008
Location: ZhengZhou China
Junior Member
select colname from tablename group by colname having count(1) > 1;

Re: unique field [message #352484 is a reply to message #352468] Wed, 08 October 2008 00:56 Go to previous message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
prt1979 wrote on Wed, 08 October 2008 04:32
select colname from tablename group by colname having count(1) > 1;

Please read OraFAQ Forum Guide:
- Format your post
- Don't put solutiobn just clue.

Regards
Michel
Previous Topic: SQL Queries (merged)
Next Topic: Dynamic cursor using ref cursor
Goto Forum:
  


Current Time: Sun Dec 11 02:35:59 CST 2016

Total time taken to generate the page: 0.08092 seconds