Views:::: Definition of Materialized View
Views:::: Definition of Materialized View
Views:::: Definition of Materialized View
View is a logical data base object, that contains some logical representation of data.
the main advantage of creating a view is we can hide some confidential information from the
other users.
Materialized views:
In case of Normal View, Normal View as a logical data base object, so it does not contain any
data.
whenever we are trying to retrieve the data from Normal View , internally data will be
loaded from the base table to view. It will leads to increase the burden on the server, to
avoid this problem we need to create a Materialized View.
As materialized view is a physical object so that we can directly access data from the
materialized view.
Definition of View
View is a virtual table, created using Create View command. This virtual table contains the data
retrieved from a query expression, in Create View command. View can be created from one or more
than one base tables or views.
Whenever a view is used the query expression in Create View command is executed at that particular
moment. Hence, you always get the updated data in a View.
If you update any content in View, it is reflected in the original table, and if any changes had been done
to the original base table, it would reflect in its View. But this makes the performance of a View slower.
For example, a view is created from the join of two or more tables. In that case, you have to pay time to
resolve Joins each time a View is used.
But it has some advantages like it do not require storage space. we can restrict the user from accessing
sensitive information in a database.
Materialized View is the Physical copy of the original base tables. The Materialized View is like a
snapshot or picture of the original base tables.
But unlike View, the Materialized View are processed and stored on a disk as an object . The
materialized view has to be updated manually or with the help of triggers
ON [trigger ]
As <query expression>
DELETE and TRUNCATE are the commands use to remove records. In SQL, DELETE
command is DML command whereas, TRUNCATE command is DDL command.
The main difference between DELETE and TRUNCATE is that using DELETE you can delete specified tuple
from a relation. But the use of TRUNCATE will delete entire tuples from a relation.
DELETE uses WHERE clause to filter the record/tuples that are to be deleted. However, TRUNCATE does
not require WHERE clause as it deletes all records
The DELETE statement removes rows one at a time and records an entry in the transaction log for each
deleted row.
TRUNCATE TABLE removes the data by deallocating the data pages used to store the table data and
records only the page deallocations in the transaction log.
Delete can be applied after deleting the child records. Cannot run truncate for a parent table with
constraints
JOINS IN ORACLE
SQL Join is used to fetch data from two or more tables, which is joined to appear as single
set of data. It is used for combining column from two or more tables by using values
common to both tables.
This type of JOIN returns the cartesian product of rows from the tables in Join. It will return a table
which consists of records which combines each row from the first table with each row of the second
table.
INNER Join or EQUI Join
This is a simple JOIN in which the result is based on matched data as per the equality condition specified
in the SQL query.
Natural JOIN
Natural Join is a type of Inner join which is based on column having same name and same datatype
present in both the tables to be joined.
The left outer join returns a result set table with the matched data from the two tables and then the
remaining rows of the left table and null from the right table's columns.
The right outer join returns a result set table with the matched data from the two tables being joined,
then the remaining rows of the right table and null for the remaining left table's columns.
The full outer join returns a resultset table with the matched data of two table then remaining rows of
both left table and then the right table.
Index
An index is a schema object that contains an entry for each value that appears in the
indexed column(s) of the table or cluster and provides direct, fast access to rows. Oracle
Database supports several types of index:
1.Normal index
2.Unique Index
3.Bit Map Index
4.Composite Index
5.B-Tree Index(Oracle considered Normal indexes as B-Tree Indexes)
6.Function Based Index
7.Clustered Index
8.Non-Clustered Index.
Unique Index:
If table contains uniquely identified values in specified column then you should use unique
index.Especially while creating the table if we specify the primary key then unique index is
automatically created on that column.But for Unique key constaint columns you separately
need to do indexing.
Bit-Map Index:
If Table contains the distinct values then user should go for Bit map indexes. We should
check drastic change in query cost after changing the normal index to Bit map index.
Composite Index:
When 2 or more columns in single table are related which each other and used in where
condition of select statement then user should create composite index on the columns
which are created.
Clustered Indexes:
1.The clustered indexes are indexes which are physically stored in order means it stores in
ascending or descending order in Database. Clustered indexes are created one for each
table. When primary key is created then clustered index has been automatically created in
the table. If table is under heavy data modifications the clustered indexes are preferable to
use.
Cron Jobs are used for scheduling tasks to run on the server. They're most commonly used for
automating system maintenance or administration. However, they are also relevant to web application
development. There are many situations when a web application may need certain tasks to run
periodically.
Timing Syntax
This is the first part of the cron job string, as mentioned above. It determines how often and when the
cron job is going to run.
Rank Vs Dense_Rank :
Rank function is used as aggregate function to return the rank of rows in the table within
group of rows. This Rank function returns the rank of values or rank of group of values in
the table.
select RANK(Rohan, OBIEE) WITHIN GROUP (ORDER BY Name, Department) from
employees;
Dense rank:
Dense rank function is useful to give the rank for the SQL values in the table. It is not
repeating the rank values so these functions are really very useful in development of reports
where we require actual rank values.
Dense_RANK () OVER (PARTITION BY expression ORDER BY expression)
Example:
The LEAD() function is used to get value from row that succedes the current row.