Jedi Codestar
Jedi Codestar

Reputation: 189

Alter view from columns in the View

I am using Oracle Database

I have View called VW_StockOpname

It has columns as follows :

S1_KL
S2_JB
S3_NB
S4_SB

It has data consists of numbers.

S1_KL | S2_JB | S3_NB | S4_SB
-----------------------------
1     | 0     | 1     | 1    
2     | 2     | 3     | 1

I would like to make another column so I can be easier to see the whole Code values

ASSETCODE 
---------
1-0-1-1
2-2-3-1

I intended to use this following code :

SELECT (ASSET_CODE AS (S1_KL ||'-'|| S2_JB ||'-'|| S3_NB ||'-'|| S4_SB)) 
FROM VW_STOCKOPNAME 

to be added to VW_STOCKOPNAME

but how can I do it? as long as I know, View can't be altered.

Meanwhile, each of the column in the view comes from different table.

Your help will be much appreciated

Upvotes: 0

Views: 160

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175586

as long as I know, View can't be altered.

Use CREATE OR REPLACE:

Specify OR REPLACE to re-create the view if it already exists. You can use this clause to change the definition of an existing view without dropping, re-creating, and regranting object privileges previously granted on it.

CREATE OR REPLACE VIEW VW_StockOpname
AS
SELECT ...

Upvotes: 1

Related Questions