Oracle Views Guide
Oracle Views Guide
Oracle Views Guide
ORACLE VIEWS
Techgoeasy.com
Oracle VIEWS
-You can specify the column names using CREATE VIEW (col1, col2) AS
SELECT COL1, COL2 FROM ;
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use only.
Oracle VIEWS
-Creating a view using CREATE FORCE VIEW will create the view with
compilation errors.
-You can create a read-only view using the WITH READ ONLY clause.
-Oracle 9i allows creating constraints on views.
-Constraints on views are not enforced, they are declarative constraints. To
enforce constraints you must create the constraints on the base tables. You
must always include the DISABLE NOVALIDATE clause when creating
constraints on views.
PRIVILEGES REQUIRED
To create a view in your own schema, you must have the CREATE VIEW
system privilege. To create a view in another users schema, you must
have the CREATE ANY VIEW system privilege.
Example of Views
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use only.
Oracle VIEWS
We can modify the views using create or replace view command. This allows
altering view without dropping, recreating and re-granting object privileges.
This command create the view if it is not existent and modify the view if it is
existent. All the plsql units which are accessing the view will become invalid
after the view modification
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use only.
Oracle VIEWS
-We can perform DML operations like insert, delete and update on the view
also with some restrictions
-A VIEW in Oracle is created by joining one or more tables. When you
update record(s) in a VIEW, it updates the records in the underlying tables
that make up the View.
-But off course you need the appropriate privileges for the underlying tables
-DML operations on views can be performed as long as the view does not
contain these words: DISTINCT, GROUP BY, START WITH, CONNECT BY,
ROWNUM, UNION [ALL], INTERSECT, MINUS or view has subqueries.
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use only.
Oracle VIEWS
-When using the WITH CHECK OPTION WITH CHECK OPTION [CONSTRAINT
<constraint_name>] clause, one can restrict the values inserted using the
views:
For example
CREATE VIEW EMP_DATA AS SELECT EMPNO, ENAME FROM EMP WHERE
EMPNO < 2000 WITH CHECK OPTION; One can use DML operation on this
view only on values smaller than 2000.
-When specifying the constraint name, Oracle will create the constraint using
specified name (otherwise will create using SYS_C followed by a unique
string).
-In order to view allowable DML operations on a view, query the
USER_UPDATABLE_COLUMNS view.
A view can be created even if the defining query of the view cannot be
executed, using the CREATE FORCE VIEW command. Such a view is called
a view with errors. This option can be useful for import/installation tools to
create a view before the underlying objects are present.
If the underlying tables are dropped, then oracle does not drop the view
automatically. It remains in the database and it will be in invalid state. If
the underlying tables are recreated, it will become valid again
Oracle VIEWS
USER_%
ALL-%
DBA_%
DBA_% views
about table
information
ALL_% views
about table
information
USER_% views
about table
information
Column
which
can be
updated
DBA_UPDATABLE_C
OLUMNS
ALL_UPDATABLE_C
OLUMNS
USER_UPDATABLE_C
OLUMNS
View
dba_views
all_views
user_views
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use only.
Oracle VIEWS
about
view
informa
tion
HOW TO EXTRACT THE VIEW DEFINITION (DDL STATEMENTS) FROM AN ORACLE DATABASE
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use only.
Oracle VIEWS
Syntax:
SQL> set long 1000
SQL> set pagesize 0
select DBMS_METADATA.GET_DDL('VIEW','<view_name>') from DUAL;
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use only.