Differences
Differences
Differences
------------------
wen we create view using any table ,the rowid of the table and view is same
but mv rowid is differnet
anlaytic
there is no row collapsing while
processing rows. therefore, return
same number of rows as the input
aggregate
aggregate take many rows collapse them into one, therfore , return single
summary value.
analytic
analytic queries also generally run faster and
use fewer resourses
analytic
the groups of rows on which an analytic function operates are defined by window
partitioning and window frame clauses.
aggregate
the groups of rows on which an agggregate function operates are defined by the sql
group by clause.
•Classification based on the Event◦DML Trigger: It fires when the DML event is
specified (INSERT/UPDATE/DELETE)
◦DDL Trigger: It fires when the DDL event is specified (CREATE/ALTER)
◦DATABASE Trigger: It fires when the database event is specified
(LOGON/LOGOFF/STARTUP/SHUTDOWN)
same cursor cannot used in two select statements whereas same refcursor can be used
in two different select statement.
A ref cursor is defined at runtime and can be opened dynamically but a regular
cursor is static and defined at compile time.
A common use for a subquery may be to calculate a summary value for use in a query.
For instance we can use a subquery to help us obtain all products have a greater
than average product price.
Contrast this with a join whose main purpose of a join is to combine rows from one
or more tables based on a match condition. For example we can use a join display
product names and models
Note that he join is an integral part of the select statement. It can not stand on
its own as a subquery can.
A subquery is used to run a separate query from within the main query. In many
cases the returned value is displayed as a column or used in a filter condition
such as where or having clause
Joins versus Subqueries. Joins and subqueries are both used to combine data from
different tables into a single result. ... Subqueries can be used to return either
a scalar (single) value or a row set; whereas, joins are used to return rows. A
common use for a subquery may be to calculate a summary value for use in a
query ...
Benefits of Triggers
---------------------------
Following are the benefits of triggers.
•Generating some derived column values automatically
•Enforcing referential integrity
•Event logging and storing information on table access
•Auditing
•Synchronous replication of tables
•Imposing security authorizations
•Preventing invalid transactions
Syntax
Consider the following example where data from the HR_RECORDS table is merged into
the EMPLOYEES table.
MERGE INTO employees e
USING hr_records h
ON (e.id = h.emp_id)
WHEN MATCHED THEN
UPDATE SET e.address = h.address
WHEN NOT MATCHED THEN
INSERT (id, address)
VALUES (h.emp_id, h.address);
How will you refresh mview and which one is default refresh
-------------------------------------------------------------------
-- Normal
CREATE MATERIALIZED VIEW view-name
BUILD [IMMEDIATE | DEFERRED]
REFRESH [FAST | COMPLETE | FORCE ]
ON [COMMIT | DEMAND ]
[[ENABLE | DISABLE] QUERY REWRITE]
AS
SELECT ...;
advantages
------------
organized code management.
Packages are easier for application designing, encapsulating data, additional
functionality and better performance. An application has various modules which can
be placed in packages and handled easier.
dbms_mview.refresh('hr',mv_name);