Professional Documents
Culture Documents
--------------------------------
in DDL is auto commit but DML is not auto commit which means its doesnot save the
values permanantly !!
The command of DML is not auto-committed that means it can't permanently save all
the changes in the database.
----------------------------------------------------------------
DDL COMMANDS:
------------
we can create , alterating and we can delete a table with help of DDL statement
CREATE
---------
Syntax: create table table_name(column_name data type);
RENAME
-------
ALTER:�
------
TRUNCATE:�
---------
Syntax: TRUNCATE�TABLE�table_name;
DROP:�
-----
----------------------------------------------------------------
DML COMMANDS:
-------------
Using DML commands we can modify the database.and then It is responsible for all
changes in the database
INSERT:�
-------
INSERT�INTO�TABLE_NAME Values(&col1,�&col2,�&col3,....�&col�N)��
UPDATE:�
--------
UPDATE�table_name�SET�[column_name1=�value1,...column_nameN�=�valueN]�[WHERE�CONDIT
ION]���
DELETE:�
-------
Syntax: DELETE�FROM�table_name�[WHERE�condition];�
TCL commands can only use with DML commands like INSERT, DELETE and UPDATE only.
((These operations are automatically committed in the database that's why they
cannot be used while creating tables or dropping them.))
COMMIT:
-------
Syntax: COMMIT;��
ROLLBACK:
---------
Syntax: ROLLBACK;
----------------------------------------------------------------
Grant
------
The GRANT command is used for providing the authorization to the users and then
REVOKE command is used for withdrawing the authorization.
PRIVILEGE:
----------
Provides permission to users.
* Object Privileges
* System Privileges
Object Privileges:
------------------
System privileges:
------------------
PROVIDING AUTHORIZATION:
The GRANT command is used for providing the authorization to the users...some of
the grant commands are....
to create a table...
________________________________________________________________
Prevent Permissions:
--------------------
REVOKE command is used for withdrawing the authorization.
Roles:
------
Role is an object created with set of privileges and password in order to maintain
user permissions effectively.
----------------------------------------------------------------
Pseudo column:
--------------
EX: Rowid
SQL> select name,rowid from mytable;
rownum:
SQL> select name,rowid,rownum from mytable;
DUAL:
----
desc dual;
----------------------------------------------------------------
CONVERSION FUNCTION
--------------------
ADD_MONTHS
Syntax: select add_months('01-jan-2009', 3) from dual;
LAST_DAY(x):
Syntax: select next_day('01-jan-2009', 'Sunday')from dual;
ROUND:
select round (to_date ('01-dec- 2009'), 'yyyy') from dual;
SYSDATE ():
----------
TRUNC:
select trunc (to_date ('06-jun-2009'), 'yyyy') from dual;
----------------------------------------------------------------
AGGREGATE FUNCTIONS � It can take many inputs and return sigle -------------------
output
1) Count()
2) Sum()
3) Avg()
4) Min()
5) Max()
GROUP BY
--------
Syntax:
-------
SELECT�column��
FROM�table_name��
WHERE�conditions���
GROUP�BY�column��
ORDER�BY�column�
examp:
HAVING
------
Syntax:
SELECT�column1,�column2���
FROM�table_name��
WHERE�conditions���
GROUP�BY�column1,�column2���
HAVING�conditions��
ORDER�BY�column1,�column2;�
ORDER BY
---------
Syntax:
SELECT�column1,�column2��
FROM�table_name��
WHERE�condition��
ORDER�BY�column1,�column2...�ASC|DESC;��
WHERE can be used to filter on table columns while HAVING can be used to filter on
aggregate function like count, sum, avg, min, and max
If filtering can be done without aggregate function then you must do it on WHERE
clause because it improves performance because counting and sorting will be done on
a much smaller set. If you filter same rows after grouping, you unnecessarily bear
the cost of sorting, which is not used.
Whenever we encounter error we can rollback from the point where we set our
SAVEPOINT
When we see the performance of Materialized view it is better than normal View
because the data of materialized view will be stored in table and table may be
indexed so faster for joining also joining is done at the time of materialized
views refresh time so no need to every time fire join statement as in case of view.
View also allows storing the definition of the query in the database itself.
1) The first difference between View and materialized view is that In Views query
result is not stored in the disk or database but Materialized view allow to store
the query result in disk or table.
3) One more difference between the View and materialized view in the database is
that In the case of View we always get the latest data but in the case of the
Materialized view we need to refresh the view for getting the latest data.
5) This is the continuation of the first difference between View and Materialized
View, In the case of view it's only the logical view of the table no separate copy
of the table but in the case of Materialized view we get a physically separate copy
of the table
We easily get a replica of data and we can perform our operation on that data
without affecting actual table data but when we see a performance that is crucial
for a large application they use a materialized view where Query Response time
matters.
So, Materialized views are used mostly with data warehousing or business
intelligence application.