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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropping all foreign keys

Status
Not open for further replies.

Powernic

Programmer
Dec 7, 2004
6
0
0
BE

Hi guys,

I need a way to drop all foreign keys of all tables on a given schema.

Does anyone know a way to do that, in an automated way?

Thanks a lot

Nicolas.
 

I found a way to do it, if anyone is interested :

select 'alter table ', tbcreator, '.', tbname, ' DROP foreign key ', name from SYSIBM.SYSTABCONST where CONSTRAINTYP = 'F'

Regards

Nicolas
 
Hi,
you can also do this

select 'alter table ',tabschema,'.',tabname, ' DROP Foreign key ', constname, ' ;' from syscat.tabconst where tabschema='URschema' and type='F' > script.dml

this will give you a file called script.dml which will have all the ALTER Table commands for all tables in ur schema with a foreign key. You can check the script before you run it so you can be sure thers nuthing wrong
Bye
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top