Solved

How to drop invalid views in DB2?

Posted on 2014-01-13
2
1,069 Views
Last Modified: 2014-01-18
Can anyone assist with situation when DB2 view has "valid=N", so after issue 'drop' command?
-
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0204N  "My_view.Name" is an undefined name.  SQLSTATE=42704.
Looking for the way that doesn't require recreate parent to this table.
Thank you
0
Comment
Question by:sevior
2 Comments
 
LVL 45

Assisted Solution

by:Kdo
Kdo earned 250 total points
ID: 39777886
Hi sevior,

Breaking this down:

DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:


Just informative.  Nothing to read there.  :)


SQL0204N  "My_view.Name" is an undefined name.  SQLSTATE=42704.

In this message, "My_view" is actually the schema name (though case should not be an issue) and "Name" is the view name.  It sounds like you're expecting something else.


Kent
0
 
LVL 25

Accepted Solution

by:
Tomas Helgi Johannsson earned 250 total points
ID: 39790510
Hi!

This command will list all views that are invalid
db2 "select viewschema.viewname from syscat.views where valid = 'N'"

This command will drop all views that are invalid
db2 -x "select 'db2 -v drop view '|| rtrim(viewschema) || '.\' || '\"' || rtrim(viewname)|| '\' || '\"' ||'' from syscat.views where valid = 'N'"

Modify these commands to your needs (if you want to say drop a specific view ).

Regards,
    Tomas Helgi
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now