Unit I Advanced SQL PDF
Unit I Advanced SQL PDF
Unit I Advanced SQL PDF
ADVANCED SQL
1
TOPIC TO BE COVERED……
1.1 Transactional Control:
Commit, Save point, Rollback
1.2 DCL Commands :
Grant and Revoke
1.3 Types of locks :
i. Row level locks
ii. Table level locks
iii. Shared lock
iv. Exclusive lock
v. Deadlock
1.4 Synonym :
Create synonym
TOPIC TO BE COVERED……
1.5 Sequences:
Create and alter sequences
1.6 Index :
Unique and composite
1.7 Views :
Create/Replace, Update and alter views
1.1 TRANSACTIONAL CONTROL
When one delete some data by mistake then to
recover/undo those data transaction control is
used.
When table regarding result of student is
created and student want to see/view their result
then student are not allowed to do changes like
insert , update , delete in result table . so to
restrict the access of student table Data control is
required.
When concurrent access is required like to
withdraw amount from your account then
concurrent access anomalies are there .this
problems are ready to solve by locks.
TRANSACTION CONTROL LANGUAGE
(TCL)
“Transaction is a set of database operation that
performs a particular task”
for example ,fund transfer from one account to
another account . updating requires in source and
destination accounts , so two database operations :
one to debit an amount in source account and to
create that amount in destination account.
a transaction must execution as a whole or as none
to maintain database consistency.
Two commands are used for TCL:
1.COMMIT
2.ROLLBACK
3.SAVEPOINT
COMMIT
Using COMMIT command a transaction can be
commited permanently.
A transaction can be committed either-
- Explicitly, or
- Implicitly
Explicit commit: to explicit a transaction
explicitly, user needs to request COMMIT
command explicitly.
A commit command terminates the current
transaction and make all changes permanents
made during the transaction.
Syntax: COMMIT;
Output: COMMIT complete.
COMMIT
Implicit commit: there are some operation
which forces a COMMIT to occur automatically,
even user don’t specify the COMMIT command.
These operation involve execution of –
1) QUIT Command:
-To end SQL*PLUS session disconnecting from
the oracle.
2) EXIT Command:
-To end SQL*PLUS session disconnecting from
the oracle.
3) Data Definition Language(DDL) Command
-Like CREATEALTER , And DROP COMMAND.
ROLLBACK
1)GRANT-granting privileges
2)REVOKE-revoking privileges
GRANT
This command is use to give permission to other
user to use our table’s data either for modification
,deletion , selection or insertion or it can be all
these four operation.
Grant a privilege on table-name to user-name.
1.Implicit Locking
- Lock which is manage by system
itself.
2.Explicit Locking
- Lock which is manage by User
itself.
IMPLICIT LOCKS:
In oracle , data in a table are locked
automatically while executing SQL statement.
This does not require any user intervention .
Such of locks are called ‘implicit locks’.
Oracle determines two issues:
2) Updateable view.
View on which data manipulation like insert,
update, delete operations are done called updatable
view.
CREATING VIEW
Syntax:
CREATE [OR REPLACE] VIEW ViewName AS
Select columnName1, columnName2…from
TableName where condition [WITH READ
ONLY];
Example:
Create view employ_details
As select emp_no, employ_name, salary from
employ;
DESTROYING A VIEW:
Syntax:
DROP VIEW viewName;
The Drop VIEW command drops the specified
view.
The base tables will not be affected if a view is
destroyed.
Example:
DROP VIEW Acc_Branch;