How to find constraints of a table using SQL

How to find constraints of a table using SQL

Post by Zhou, Xiaodon » Sun, 25 Feb 2001 14:23:18



Hi, there:

I want to see the constraints(foreign key, primary key, etc.) of a table.  I
don't know how to do it in SQL.  Will you please give me some advice?
Thanks in advance!

Yours xdzhou

 
 
 

How to find constraints of a table using SQL

Post by Pint » Sun, 25 Feb 2001 15:03:31


select * from user_constraints where table_name=<table_name>

Pinto


>Hi, there:

>I want to see the constraints(foreign key, primary key, etc.) of a table.
I
>don't know how to do it in SQL.  Will you please give me some advice?
>Thanks in advance!

>Yours xdzhou


 
 
 

How to find constraints of a table using SQL

Post by Richard Sutherlan » Sun, 25 Feb 2001 20:55:28


For constraints or anything else, take a look at Perl module DDL::Oracle,
available from the CPAN, and from:

    http://sourceforge.net/projects/ddl-oracle/

Richard Sutherland


Quote:> Hi, there:

> I want to see the constraints(foreign key, primary key, etc.) of a table.
I
> don't know how to do it in SQL.  Will you please give me some advice?
> Thanks in advance!

> Yours xdzhou

 
 
 

How to find constraints of a table using SQL

Post by Brian Peaslan » Mon, 26 Feb 2001 01:39:56


You will need two data dictionary views, USER_CONSTRAINTS and
USER_CONS_COLUMNS. This first one will tell you all the constraints you
have on all of your columns. Since constraints tend to apply to specific
columns of a table, the USER_CONS_COLUMNS will help too!

HTH,
Brian


> Hi, there:

> I want to see the constraints(foreign key, primary key, etc.) of a table.  I
> don't know how to do it in SQL.  Will you please give me some advice?
> Thanks in advance!

> Yours xdzhou

--
========================================
Brian Peasland
Raytheons Systems at
  USGS EROS Data Center
These opinions are my own and do not
necessarily reflect the opinions of my
company!
========================================
 
 
 

How to find constraints of a table using SQL

Post by Brian Peaslan » Mon, 26 Feb 2001 01:38:56


Quote:> For constraints or anything else, take a look at Perl module DDL::Oracle,
> available from the CPAN, and from:

>     http://sourceforge.net/projects/ddl-oracle/

> Richard Sutherland

How's that for a plug for a product?

Cheers,
Brian

--
========================================
Brian Peasland
Raytheons Systems at
  USGS EROS Data Center
These opinions are my own and do not
necessarily reflect the opinions of my
company!
========================================

 
 
 

How to find constraints of a table using SQL

Post by Richard Sutherlan » Mon, 26 Feb 2001 07:10:47


Perl modules available from the CPAN are open source software.  They are
available for download without charge.  DDL::Oracle is available under the
terms of the Artistic license, which is the license under which Perl is
distributed.

Enjoy!

Richard Sutherland


Quote:

> > For constraints or anything else, take a look at Perl module
DDL::Oracle,
> > available from the CPAN, and from:

> >     http://sourceforge.net/projects/ddl-oracle/

> > Richard Sutherland

> How's that for a plug for a product?

> Cheers,
> Brian

> --
> ========================================
> Brian Peasland
> Raytheons Systems at
>   USGS EROS Data Center
> These opinions are my own and do not
> necessarily reflect the opinions of my
> company!
> ========================================