S-24
S-24
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 1 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
e) Define: 2M
i) Data Abstraction
ii) Data Redundancy
Page 2 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 3 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
g) Define: 2M
i) Instance
ii) Schema Each
Ans. i) Instance: An instance in DBMS is essentially a snapshot of the definition 1M
data stored in a database at a specific point in time.
UNION Operation:
UNION is used to combine the results of two or more SELECT
statements. However it will eliminate duplicate rows from its
resultset. In case of union, number of columns and data type must be
same in both the tables, on which UNION operation is being applied.
SELECT * FROM employee
UNION
SELECT * FROM Worker;
Page 4 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
UNION ALL:
This operation is similar to Union. But it also shows the duplicate
rows.
SELECT * FROM employee
UNION ALL
SELECT * FROM Worker;
INTERSECT:
Intersect operation is used to combine two SELECT statements, but it
only returns the records which are common from both SELECT
statements.
SELECT * FROM employee
Intersect
SELECT * FROM Worker;
MINUS:
The Minus operation combines results of two SELECT statements
and return only those in the final result, which belongs to the first set
of the result.
SELECT * FROM employee
Minus
SELECT * FROM Worker;
Page 5 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 6 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
OR REPLACE Allows you to create synonym (if it already exists) Drop synonym
without having to issue a DROP command. syntax with
explanation
PUBLIC :Creates a synonym accessible to all users. 1M,
object_name: The name of object for which you are creating the
synonym. It can be table, view, sequences, stored procedure, function, Example 1M
synonym and other database object.
Drop synonym
Syntax: drop synonym <synonym_name>;
Page 7 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Supplier
SNO SNAME LOCATION
S1 Abc Mumbai
S2 Pqr Pune
S3 Lmn Delhi
SP
S2 P2 300
S3 P1 400
Page 8 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
3. Disk Storage:
Data files: It stores the database.
Data Dictionary: It stores metadata that hold particular values.
Indices: Provide fast access to data items that hold particular values.
Statistical data: It stores statistical information about the data in the
database.
Page 9 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 10 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
3. Closing a cursor.
The close statement disables the cursor and active set becomes
undefined. This will release the memory occupied by cursor and
its dataset both on the client and on the server.
Syntax:
CLOSE cursorname;
Page 11 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Example:
Syntax :truncate table <tablename>;
Example :truncate table emp;
Page 12 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Syntax:
SELECT
tablename.column1_name,tablename.column2_name
FROM table_name1,table_name2
where
table_name1.column_name=table_name2.column_nam
e;
Example:
Select stud_info.stud_name, stud_info.branch_code,
branch_details.location
From stud_info, branch_details
Where
Stud_info.branch_code=branch_details.branch_code;
2) SELF JOIN:
The SQL SELF JOIN is used to join a table to itself, as if the table
were two tables, temporarily renaming at least one table in the SQL
statement.
Syntax:
SELECT a.column_name, b.column_name
FROM table1 a, table1 b
WHERE a.common_filed = b.common_field;
Example:
Select x.stud_name, y.stud_name
from stud_info x, stud_info y
Where x.leader= y.stud_id;
Page 13 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
any_alias2.columnname;
OR
Select column1_name,column2_name
from table1name left outer join table2name
on table1name.columnname= table2name.columnname;
Example:
select last_name, department_name
from employees e, departments d
on e.department_id(+) = d.department_id;
OR
select last_name, department_name
from employees left outer join departments
on employees.department_id =
departments.department_id;
Page 14 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Correct
Entities 1M
Correct
relation
ships
1M
Page 15 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 16 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
(OR)
Page 17 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Update emp_details
Set name= „Rajani‟
Where emp_ID=1111;
Drop Index:
Syntax: Drop index <index_name>;
(OR)
Example:(Assuming idx_empno created on employee table)
Drop index idx_empno;
Page 18 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 19 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
exception_section;]
END
[function_name];
Example create or replace CREATE OR
function circle_area(r REPLACE
number) PROCEDURE
return number greetings
is AS
area number; BEGIN
pi constant dbms_output.put_line('
number(3,2):=3.14; Hello World!');
begin END;
area := pi*r*r; /
return area;
end circle_area;
Page 20 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
To delete a trigger:
DROP TRIGGER stud_marks;
Page 21 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
(iii)Display all books whose price is between Rs.500 & Rs. 800
SQL> Select * from Book_Master where price between 500 and800;
OR
SQL> Select * from Book_Master where price >=500
andprice<=800;
(iv) Display all books with details whose name start with ‘D’
SQL> Select bookname from Book_Master where bookname like
„D%‟;
Page 22 / 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 23 / 23