Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There's no way to alter a view using iSeries Navigator. However, if you are open to using a SQL statement AND you are on v7.1 or greater, you can use the new "CREATE OR REPLACE VIEW" command: <a href="http://iprodeveloper.com/database/use-sql-create-or-replace-improve-db2-i-object-management" rel="nofollow">SQL CREATE OR REPLACE syntax</a>.</p> <p>This will allow you to alter existing views without first needing to drop dependent objects. For example consider a view named "VIEW2" that consumes a column named "DESC" from "VIEW1". You could add a column to "VIEW1" without affecting "VIEW2" using the following command:</p> <pre><code>CREATE OR REPLACE VIEW MYSCHEMA.VIEW1 AS SELECT DESC, NEWCOL FROM MYSCHEMA.MYTABLE; </code></pre> <p>Similarly, you can drop a column from "VIEW1" without affecting other views. The only restriction is that you cannot drop a column that is used by another view (or function, alias, etc.) If you try to drop a column that another view is dependent upon, you will receive an error message.</p> <p>Using the "REPLACE" method will also preserve any permissions/security constraints.</p> <p>It should be noted that a more ideal method would be to automate the creation of views/functions/procs/aliases/etc via scripts. This would allow you to drop and recreate dependent objects in a consistent manner. This presumes some manner of automation around your database management, and may present issues if you have a very large number of dependent objects (of if you have a large number of indexed views.) The biggest risk with having a large number of "REPLACE" scripts is that they will be applied incorrectly, either by not applying one of the scripts or by applying them in the wrong order.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload