Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to look for constraints in a Table

Status
Not open for further replies.

thendal

Programmer
Joined
Aug 23, 2000
Messages
284
Hi all!

I am new to oracle db.what query do i need to use if i need to know about the constraints in the table eg: whether it has a primary key etc..

to know about the table structure i placed the command

desc tablename;

it displyed all the field name and thier data types.....

Any help will be greatly appriciated

Thanks

Thendal
 
Explore all_constraints or dba_constraints. The structure of that views is self-describing.
 
Thanks sem for the quick response ...

I am afraid you misunderstood my question....

For example if you were asked to explore a table which is not created by you....but you need to know what are the field names and if there is any primary key etc....


Is there any query for that..or inbuild function in oracle...

is that explore all_constraints /dba_constraints is a query or a function in oracle...i tried in the command line
it didn't work..

-
 
Try:

SELECT *
FROM DBA_CONSTRAINTS
WHERE OWNER = 'Name_Of_Owner_Of_Table';

Terry M. Hoey
 
Querying on DBA_CONSTRAINTS will give you information at the table level (e.g., what is the name of the constraint, what type of constraint is it, etc). DBA_CONS_COLUMNS will give you information at the column level (e.g., which column(s) are involved with the constraint, as well as where in the column list a given column appears for composite constraints, etc).
 
Thanks a lot for the info...

Thendal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top