Oracle-3
Oracle-3
Syntax:
Select ColumnName1, Column Name2 from ViewName;
Example:
Select * from v1;
Updateable Views:
Example
Delete from v1 where no=500;
Destroying a view
Syntax:
Drop view <View Name>>
Example
Drop view v1;
EXPLAIN SEQUENCE IN DETAIL.
SEQUENCES
Syntax:
Create sequence Sequence Name
[Increment By <Integer Value>
Start With <Integer Value>
Maxvalue <Integer Value> / NonMaxvalue
Minvalue <Integer Value> / Nonminvalue
Cycle/NoCycle
Cache <Integer Value> / No Cache
Order / Noorder]
Example:
Create sequence s1 start with 5 increment by 1 maxvalue 50;
To reference next value of sequence
Syntax:
Select Sequence Name.Nextval from dual;
· This will display the next value held in the cache.
· Every time nextval references a sequence its output
is automatically incremented from the old value to
the new value ready for user.
Example:
Select s1.nextval from dual;
Example
Select stest1.currval from dual;
Altering a Sequence
Syntax:
Alter sequence <<Sequence Name>>
Incremented by interger value
Maxvalue Integer Value/ Nomaxvalue
Example:
Dropping a Sequence:
Syntax:
Drop Sequence <<Sequence Name>>;
Example:
Drop Sequence stest1;
Syntax:
Create Synonym Synonym.Name for Table Name
Example:
Create synonym employees for emp;
Dropping
Synonyms Syntax:
Drop Synonym Synonym.Name;
Example
Drop Synonym employees;
Duplicate index:
Index that allows duplicate value for the
indexed column.
Unique index:
Index that only unique value for the indexed
column.
Duplicate index:
1) Simple duplicate index
An index created on a single column of a table
is called simple index.
Syntax:
Create index <index name> on <table name> (<column
name>);
Example:
Create index i1 on emp (empno);
Unique index:
1) Unique simple index:
Syntax:
Create unique index <index name> on <table
Exampl
e:
Create unique index i1 on emp (empno);
Syntax:
Create unique index <index name> on <table name> (<column name1>, <column name2>);
Example:
Create unique index i1 on emp (empno, ename)
Object Privileges:
A user can grant all the privileges or grant only specific
object privileges.
EXAMPLE:
GRANT select, update ON emp TO
bca15;
Revoke
The REVOKE statement is used to deny the grant given
on
an object.
Syntax:
REVOKE <Object Privileges> ON <Object Name> FROM <User Name>;
EXAMPLE:
REVOKE delete ON emp FROM pgdca20;
Example:
CREATE USER ABC IDENTIFIED BY aa1234;
Now, user is created but user cannot login into oracle.
DBA has to assign rights to user so that user can get connected
and can run sql statements.
Syntax:
COMMIT
Rollback
· A ROLLBACK does exactly the opposite of COMMIT.
· It ends the transaction but undoes any changes made
during the transaction.
· All transactional locks acquired on tables are released.
Syntax:
ROLLBACK [WORK] [TO [SAVEPOINT] <Save Point Name>];
· WORK Is optional and is provided for ANSI compatibility.
· SAVEPOINT Is optional and used to rollback a
transaction partially, as far as the specified save point.
· SAVEPOINT NAME Is a name of save point
created during the current transaction.
Save Point
· SAVEPOINT marks and saves the current point in
the processing of a transaction.
· When a SAVEPOINT is used with a ROLLBACK
statement, parts of a transaction can be undone.
Syntax:
SAVEPOINT <Save Point Name>;
DETAILING:
- THERE ARE THREE TYPES OF
TRANSACTION CONTROL COMMAND. LIKE
COMMIT
,ROLLBACK AND SAVEPOINT.
1) COMMIT:-
- COMMIT STATEMENT IS USED TO
SAVE WORK IN DATA BASE.
- COMMIT IS EXECUTE ALL THE
SQL STATEMENT.
- COMMIT ALSO USED TO END
OF TRANSACTION.
2) ROLLBCAK :-
- ROLLBACK STATEMENT IS USED TO
UNDO THE WORK .
- ROLLBACK CAN PERFORM
DISCARD CHAGES.
- THE SUCCESSFUL END OF TRANSACTION.
3) SAVE POINT:-
- IT IS USED TO IDENTIFY A POINT
IN TRANSACTION.
- SAVE POITN IS POINT BY POINT
DATA SAVING COMMAND.
- SAVE POINT IS LIKE MARKER TO DEVICE
THAT CONVERT LENGHTLY
TRANSACTION INTO SMALLER ONE.
1) DDL LOCK:-
- DDL MEANS DATA DEFINITION LAMGUAGE.
- DDL LOCK DDL STATEMENT LIKE
CREATE,ALTER,GRANT AND
REVOKE.
2) DML LOCK:-
- DML MEANS DATA
MANIPULATION LANGUAGE.
- IT PROTECT DML STATEMENT.
- LIKE INSERT, UPDATE AND
DELETE STATEMENT LOCK .
EX:-
SELECT * FROM BCA ORDER BY NAME;
EX.
SELECT * FROM BCA ORDER BY NAME
DESC;