| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Finding Not Null Constraints
: John Hough wrote:
You can't do it in SQL alone; you need PL/SQL to parse the long. I chose to copy the constraints views into my own tables, which solves the long problem and also (because of the primary key indices) makes joins inordinately faster. The only drawback is that you need to regenerate the tables as often as your schema changes.
create table uc(
constraint_name varchar2(30) constraint pk_uc primary key,
constraint_type varchar2(30),
table_name varchar2(30),
search_condition varchar2(2000),
r_constraint_name varchar2(30)
constraint_name varchar2(30),
table_name varchar2(30),
column_name varchar2(30),
declare
cursor user_constraints_cur is
select *
from user_constraints;
cursor user_cons_columns_cur is
select *
from user_cons_columns;
begin
for rec in user_constraints_cur loop
insert into uc (constraint_name, constraint_type, table_name, search_condition, r_constraint_name) values(rec.constraint_name, rec.constraint_type, rec.table_name, rec.search_condition, rec.r_constraint_name);end loop;
for rec in user_cons_columns_cur loop
insert into ucc (constraint_name, table_name, column_name) values(rec.constraint_name, rec.table_name, rec.column_name);end loop;
end;
/
select count(*) from uc, ucc where uc.constraint_name = ucc.constraint_name and upper(uc.search_condition) = ucc.column_name || ' IS NOT NULL';
Cheers,
-- | Dave Schweisguth For purposes of complying with | | dcs_at_proton.chem.yale.edu (MIME OK) the New Jersey Right to Know Act: | | http://proton.chem.yale.edu/~dcs/ Contents partially unknown. | | Yale Depts. of MB&B & Chemistry Phone: 203-432-5208 Fax: 203-432-6144 |Received on Sun Apr 27 1997 - 00:00:00 CDT
![]() |
![]() |