Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 10th, 2008, 07:47 PM
Expert
 
Join Date: Nov 2006
Posts: 351
Default Viewing table constraints

I am trying to delete a row from a table in DB2. When I run the SQL below I get the error shown due to a table constraint. The problem I am running into is that I can not find a way to get DB2 to show me the constraint in question. So I do not know what other table or tables are related and blocking my delete.

SQL:
Expand|Select|Wrap|Line Numbers
  1. SELECT *  
  2. FROM sysadm.tb_ec3_bus_area 
  3. WHERE b_area_nam ='Blah Blah'
  4.  

Error :
Expand|Select|Wrap|Line Numbers
  1. SQL0532N  A parent row cannot be deleted because the relationship "C2ECPYRF" 
  2. restricts the deletion.  SQLSTATE=23504
  3.  


When I tried to run describe against the table I get this error.

SQL:
Expand|Select|Wrap|Line Numbers
  1. DESCRIBE table sysadm.b_area_nam
  2.  

Error :
Expand|Select|Wrap|Line Numbers
  1. DESCRIBE table sysadm.tb_ec_bus_area
  2. DB21033E  The command is not valid for databases that reside on DRDA hosts.
  3.  


When I looked up the table in the DB2 Control Center tool it does not show any constraints, or foreign keys.


Anyone know how I can get DB2 to show me what is constraining or restricting this table?
Reply
  #2  
Old September 11th, 2008, 04:09 PM
docdiesel's Avatar
Moderator
 
Join Date: Aug 2007
Location: Munich
Posts: 281
Default

Hi,

try to use the command line tool db2look:
Expand|Select|Wrap|Line Numbers
  1. db2look -a -e -d dbname -o outputfile.ddl
In outputfile.ddl you'll find a definition of all database objects and within there the table and its contraints. Another way is to habe a look at the system table sysibm.table_constraints:

Expand|Select|Wrap|Line Numbers
  1. select  *
  2. from    sysibm.table_constraints
  3. where   CONSTRAINT_NAME='xxxxx'
Regards

Doc Diesel
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles