Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

What I ever wanted to ask: (1) column name list in views

marindoMay 12 2017 — edited May 15 2017

Hi there!

There are a few things I ever wanted to ask, such as...

(1) What is the reason for listing the columns in a view?

When I create a view like this...

CREATE VIEW my_view AS SELECT col_a, col_b, col_d FROM ... WHERE ...

it is later on displayed (in SQL developer) as

CREATE OR REPLACE FORCE VIEW "MY_ACCOUNT"."MY_VIEW" (COL_A, COL_B, COL_C) AS

SELECT

col_a,

col_b,

col_c

FROM ... WHERE ...;

When I want to edit the view, I copy/paste that into a SQL developer window, make my changes and run the code. Fine. But for what reason is the list of columns following the view name? E.g. When I add a column, I need to delete the column list before running the code. Because if the view is like this:

CREATE OR REPLACE FORCE VIEW "MY_ACCOUNT"."MY_VIEW" (COL_A, COL_B, COL_C) AS

SELECT

col_a,

col_b,

col_c,

col_d

FROM ... WHERE ...;

the added column col_d will be invisible, e.g. select col_d from my_view will result in an error message.

It looks like the column list is completely unnecessary. But maybe I am overlooking something? Any idea?

This post has been answered by marindo on May 15 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2017
Added on May 12 2017
19 comments
1,716 views