Welcome to plsql4all.blogspot.com SQL, MYSQL, ORACLE, TERADATA, MONGODB, MARIADB, GREENPLUM, DB2, POSTGRESQL.

Saturday 20 June 2015

How to create a view on a table that does not exist?

we can create a view on a table that really doesn't exist yet we can do this by putting
a word (Force) in create view command-

SYNTAX

CREATE FORCE VIEW
        <VIEW_NAME>
                AS
         <SELECT STATEMENT>;      -- ASSUMING THE TABLE DOES NOT EXIST


e.g.

CREATE FORCE VIEW DEPARTMENT_FORCE_VW AS
SELECT * FROM DEPARTMENT;


Here view gets created but its status is invalid, it becomes valid when we create table DEPARTMENT
(table on which view is defined).

No comments:

Post a Comment

Please provide your feedback in the comments section above. Please don't forget to follow.