468,315 Members | 1,457 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

fetching field information from oracle db

Hi there,

as I am trying to write a recordset class, I am interested in fetching
field information from an oracle db. Several information on the fields
are very simple to request. So I already receive the field properties
name, max_length, type not_null, has_default and defaul_value. This is
achieved by using functions like oci_field_name(). But I am not able to
request the information on if the field is primary key or marked as
unique key.

Is there a way to fetch the properties unique and primary key?

thanks,
;) Florian

Feb 13 '06 #1
2 1224
On Mon, 13 Feb 2006 00:33:14 -0800, Florian Albrecht wrote:
Is there a way to fetch the properties unique and primary key?


select col.owner,col.table_name,col.column_name,col.const raint_name
from dba_constraints con,dba_cons_columns col
where con.owner=col.owner and
con.table_name=col.table_name and
con.constraint_name=col.constraint_name and
con.constraint_type in ('P','U') and
con.table_name=:TABLE and
con.owner=:OWNER

You can user all_constraints and all_cons_columns instead the dba
varieties, even LUSER_CONSTRAINTS and LUSER_CONS_COLUMNS.
--
http://www.mgogala.com

Feb 13 '06 #2
Mladen Gogala wrote:
On Mon, 13 Feb 2006 00:33:14 -0800, Florian Albrecht wrote:

Is there a way to fetch the properties unique and primary key?

select col.owner,col.table_name,col.column_name,col.const raint_name
from dba_constraints con,dba_cons_columns col
where con.owner=col.owner and
con.table_name=col.table_name and
con.constraint_name=col.constraint_name and
con.constraint_type in ('P','U') and
con.table_name=:TABLE and
con.owner=:OWNER

You can user all_constraints and all_cons_columns instead the dba
varieties, even LUSER_CONSTRAINTS and LUSER_CONS_COLUMNS.

--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Feb 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Sachin | last post: by
reply views Thread by remcoploeg | last post: by
22 posts views Thread by Sandman | last post: by
reply views Thread by =?Utf-8?B?SGF3aw==?= | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.