If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Table relationship with view in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-25-12, 03:06
junaid377 junaid377 is offline
Registered User
 
Join Date: Jan 2012
Posts: 40
Table relationship with view in DB2

I am using db2 9.1 on redhat linux 5.1

I know that before dropping a table we must drop all constraints, references,triggers and procedures.

But my question is do we have to drop all views before dropping a table..

My actual scenario is that I have to drop a table and move it into a different tablespace... for that I need to drop the table and recreate it in a different table space with the same structure....


Will I Need to drop all views on that table before dropping the table...

or is it possible to drop the table and recreate it without having to drop and recreate the views
Reply With Quote
  #2 (permalink)  
Old 01-25-12, 03:09
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
yes you can drop a table without dropping the view
the view will be invalid
when creating again the view it will become valid if all conditions are valid
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 01-25-12, 19:51
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You won't have to remove unique/primary keys and/or referential constraints (or any other constraints). They will be removed along with the table. Also, triggers and procedures may automatically be invalidated as well.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 01-26-12, 03:17
dr_te_z dr_te_z is offline
Registered User
 
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
Quote:
Originally Posted by stolze View Post
You won't have to remove unique/primary keys and/or referential constraints (or any other constraints). They will be removed along with the table. Also, triggers and procedures may automatically be invalidated as well.
Yeah, awareness is important here:
At the latest IDUG in Prague I learned (from Scott) about the usefull parameter setting:
Code:
pctfree 0 page split high
if your index has an guaranteed ascending sequence. As all our PK's are composed of generated columns I brewed a script to drop all PK contraints & indexes and rebuilt them acoording to the new rules I'd just learned......

Not a good idea: I lost all my FK-contraints because they are dropped together with the PK-constraint on the parent-table (I sence a "delete cascade" smell here).
Luckely I found out in my test systems on time so I dropped the idea instead of the PK's
Reply With Quote
  #5 (permalink)  
Old 01-26-12, 13:42
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Not surprising, I'd say. Each FK has to reference a unique constraint (PK is just a unique constraint). If that referenced constraint vanishes, the FK vanishes.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On