1

I need to add a column to the view but I cannot find the right way to this. Please provide me with a proper syntax. I need to add the column "NextFeeDate" from table "T_atmcardparam" to the "atmcardparam".

ALTER VIEW view_name
("column 1", "col 2", "col3", "col4")
SELECT ("col5", "col6", "col7", "col8")
FROM table_name

I found this syntax online but don't know how to implement it.

Dale K
  • 25,246
  • 15
  • 42
  • 71
Trincula
  • 59
  • 9

2 Answers2

0

There is no alter view syntax to add a column - you just recreate it with the new query using the or replace clause. E.g.:

CREATE OR REPLACE VIEW view_name
("column 1", "col 2", "col3", "col4")
AS 
SELECT ("col5", "col6", "col7", "col8")
FROM table_name
Mureinik
  • 297,002
  • 52
  • 306
  • 350
0

You have to write the entire view again and just add or omit what you want to change....

for the first time you have to create the view..

create view view_name as
  select field_name
  from table_name

and then you have to add a column in table using alter the view

alter view view_name as
      select field_name,
      field_name2
      from table_name

2nd Option is that you have to open script the view as Alter, and then alter the select statement that generates the view.

For more info....try this...https://www.w3schools.com/sql/sql_view.asp

THE LIFE-TIME LEARNER
  • 1,476
  • 1
  • 8
  • 18