DBMS Notes
DBMS Notes
2. ALTER: It is used to alter the structure of the database. This change could be either
to modify the characteristics of an existing attribute or probably to add a new
attribute.
Syntax:
To add a new column in the table:
ALTER TABLE table_name ADD column_name (column-definition);
To modify existing column in the table: ALTER TABLE table_name MODIFY
(column_definition);
Example:
ALTER TABLE stu_details ADD (address VARCHAR2(20));
ALTER TABLE stu_details MODIFY (name VARCHAR2(20));
3. DROP: It is used to delete both the structure and the records stored in the table.
Syntax: DROP TABLE table_name;
Example: DROP TABLE employee;
4. TRUNCATE: It is used to delete all the rows from the table and free the space
containing the table.
Syntax: TRUNCATE TABLE table_name;
Example: TRUNCATE TABLE employee;
2. UPDATE: This command is used to update or modify the value of a column in the
table.
Syntax: UPDATE table_name SET column_name1= value1 WHERE [condition];
Example: UPDATE students SET User_Name = 'Sonoo'
WHERE Student_Id = '3';
4. SELECT: The SELECT statement is used to select data from a database. The data
returned is stored in a result table, called the result-set.
Syntax: SELECT column-name FROM table_name;
Example: SELECT emp_name FROM employee;
3. Commit: Commit command is used to save all the transactions to the database.
Example: DELETE FROM CUSTOMERS
WHERE AGE = 25;
COMMIT;
4. Rollback: Rollback command is used to undo transactions that have not already been
saved to the database.
Example:
DELETE FROM CUSTOMERS
WHERE AGE = 25;
ROLLBACK;
5. Savepoint: It is used to roll back to the transaction back to a certain point without
rolling back the entire transaction.
Syntax: SAVEPOINT savepoint_name;
INTEGRITY CONSTRAINTS:
Integrity Constraints in Database Management Systems are the set of pre-defined
rules responsible for maintaining the quality and consistency of data in the database.
Evaluation against the rules mentioned in the integrity constraint is done every time
an insert, update, delete, or alter operation is performed on the table.
2. Entity Constraint:
Primary key: The entity integrity constraint states that primary key value can't be
null. This is because the primary key value is used to identify individual rows in
relation and if the primary key has a null value, then we can't identify those rows. A
table can contain a null value other than the primary key field.
Example: primary key (rollno);
3. Referential Constraint:
Foreign Key: A foreign key is the one that is used to link two tables together via the
primary key. It means the columns of one table points to the primary key attribute of
the other table.
Example: create table emp (eid number (3) primary key, ename varchar (30));
create table emp1 (eid number (3) references emp(eid), ename varchar (30));
4. Key Constraint:
Candidate Key: In a single table, more than one column as a primary key is called as
candidate key.
Example: primary key (sname, rollno);
OPERATORS:
1. Arithmetic Operators: Arithmetic operators can perform arithmetic operations on
numeric operands involved. Arithmetic operators are addition (+), subtraction (-),
multiplication (*) and division (/).
1. Addition (+): SELECT (4+3) FROM DUAL;
2. Subtraction (-): SELECT (4-3) FROM DUAL;
3. Multiplication (*): SELECT (4*3) FROM DUAL;
4. Division (/): SELECT (12/3) FROM DUAL;
2. Set Operators: SQL provides set operators to compare rows from two or more tables or to
combine the results obtained from two or more queries to obtain the final result. These
operators are used to join the results of two (or more) SELECT statements. These are:
There are different types of set operators that are mentioned below:
1. UNION: UNION eliminates the duplicate rows from the results.
Syntax: SELECT * FROM table1 UNION SELECT * FROM table2;
2. UNION ALL: UNION ALL prints all the values in the result.
Syntax: SELECT * FROM table1 UNION ALL SELECT * FROM table2;
3. MINUS: The MINUS operator allows you to filter out the results which are present in
the first table but absent in the second table.
Syntax: SELECT * FROM table1 MINUS SELECT * FROM table2;
4. INTERSECT: The INTERSECT operator allows you to find the results that exist in both
queries.
Syntax: SELECT * FROM table1 INTERSECT SELECT * FROM table2;
3. Pattern Matching Operator: LIKE clause is used to perform the pattern matching task in
SQL. LIKE clause searches for a match between the patterns in a query with the pattern in
the values present in an SQL table. LIKE clause can work with strings and numbers.
Syntax: SELECT * FROM table_name LIKE colum_name = condition;
Example: SELECT * FROM emp LIKE city = ‘P___’;
FUNCTIONS:
1. Aggregate Function: SQL aggregation function is used to perform the calculations on
multiple rows of a single column of a table. It returns a single value. It is also used to
summarize the data.
1. COUNT: Count function is used to Count the number of rows in a database table. It
can work on both numeric and non-numeric data types.
Syntax: SELECT COUNT (column_name) FROM table_name;
Example: SELECT COUNT (name) FROM emp;
2. SUM: Sum function is used to calculate the sum of all selected columns. It works on
numeric fields only.
Syntax: SELECT SUM (column_name) FROM table_name;
Example: SELECT SUM (salary) FROM emp;
3. AVG: The average function is used to calculate the average value of the numeric
type.
Syntax: SELECT AVG (column_name) FROM table_name;
Example: SELECT AVG (salary) FROM emp;
4. MAX: Maximum function is used to find the maximum value of a certain column.
Syntax: SELECT MAX (column_name) FROM table_name;
Example: SELECT MAX (salary) FROM emp;
5. MIN: Minimum function is used to find the minimum value of a certain column.
Syntax: SELECT MIN (column_name) FROM table_name;
Example: SELECT MIN (salary) FROM emp;
1. ABS (): This SQL ABS () returns the absolute value of a number passed as an
argument.
2. CEIL (): This SQL CEIL () will round up any positive or negative decimal value within
the function upwards.
3. FLOOR (): The SQL FLOOR () will round up any positive or negative decimal value
down to the next least integer value.
4. MOD (): This SQL MOD () function returns the remainder from a division.
5. POWER (): This SQL POWER () function returns the value of a number raised to
another, where both of the numbers are passed as arguments.
6. SQRT (): The SQL SQRT () returns the square root of given value in the argument.
3. String Functions: String functions are used to perform an operation on input string and
return an output string. Following are the string functions defined in SQL:
4. Date and Time Functions: Date and time functions are used to perform an operation on
dates and times. Following are the date and time functions defined in SQL:
CLAUSES:
1. GROUP BY: SQL GROUP BY statement is used to arrange identical data into groups. The
GROUP BY statement is used with aggregation function.
Syntax: SELECT column FROM table_name
GROUP BY column;
Example:
SELECT company, count (*) FROM products
GROUP BY company;
2. HAVING: HAVING clause is used to specify a search condition for a group or an aggregate.
Having is used in a GROUP BY clause. If you are not using GROUP BY clause then you can use
HAVING function like a WHERE clause.
Syntax: SELECT column1, column2 FROM table_name
GROUP BY column1, column2 HAVING conditions;
Example: SELECT company, count (*) FROM products
GROUP BY company HAVING count (*)>2;
3. ORDER BY: The ORDER BY clause sorts the result-set in ascending or descending order. It
sorts the records in ascending order by default. DESC keyword is used to sort the records in
descending order.
Syntax: SELECT column1, column2 FROM table_name
ORDER BY column1, column2... [DESC];
Example: SELECT * FROM customer
ORDER BY name;
ER DIAGRAM:
ER diagram stands for Entity-Relationship Diagram. It is a high-level data model. This
model is used to define the data elements and relationship for a specified system.
It develops a conceptual design for the database. It also develops a very simple and
easy to design view of data.
In ER modelling, the database structure is portrayed as a diagram called an entity-
relationship diagram.
Components of ER Diagram:
1. Entity: An entity may be any object, class, person or place. In the ER diagram, an entity
can be represented as rectangles.
1. Weak Entity: An entity that depends on another entity is called a weak entity. The
weak entity doesn't contain any key attribute of its own. The weak entity is
represented by a double rectangle.
2. Attribute: The attribute is used to describe the property of an entity. Ellipse is used to
represent an attribute.
1. Key Attribute: The key attribute is used to represent the main characteristics of an
entity. It represents a primary key. The key attribute is represented by an ellipse with
the text underlined.
2. Composite Attribute: An attribute that composed of many other attributes is known
as a composite attribute. The composite attribute is represented by an ellipse, and
those ellipses are connected with an ellipse.
3. Multivalued Attribute: An attribute can have more than one value. These attributes
are known as a multivalued attribute. The double oval is used to represent
multivalued attribute.
4. Derived Attribute: An attribute that can be derived from another attribute is known
as a derived attribute. It can be represented by a dashed ellipse.
1. One-to-One Relationship: When only one instance of an entity is associated with the
relationship, then it is known as one-to-one relationship.
2. One-to-many relationship: When only one instance of the entity on the left, and
more than one instance of an entity on the right associates with the relationship
then this is known as a one-to-many relationship.
3. Many-to-one relationship: When more than one instance of the entity on the left,
and only one instance of an entity on the right associates with the relationship then
it is known as a many-to-one relationship.
4. Many-to-many relationship: When more than one instance of the entity on the left,
and more than one instance of an entity on the right associates with the relationship
then it is known as a many-to-many relationship.
VIEW:
Views in SQL are considered as a virtual table. A view also contains rows and columns. To
create the view, we can select the fields from one or more tables present in the database. A
view can either have specific rows based on certain condition or all the rows of a table.
Syntax:
CREATE VIEW view_name AS
SELECT column1, column2...columnN FROM table_name
WHERE condition;
Example:
CREATE VIEW DetailsView AS
SELECT NAME, ADDRESS FROM Student_Details
WHERE STU_ID < 4;
SYNONYMS:
A synonym provides another name for database object, referred to as original object, that
may exist on a local or another server. A synonym belongs to schema, name of synonym
should be unique. A synonym cannot be original object for an additional synonym and
synonym cannot refer to user-defined function.
INDEX:
An index is a schema object. It is used by the server to speed up the retrieval of rows by
using a pointer. An index helps to speed up select queries and where clauses, but it slows
down data input, with the update and the insert statements. Indexes can be created or
dropped with no effect on the data.
SEQUENCES:
A sequence is a user defined schema bound object that generates a sequence of numeric
values. Sequences are frequently used in many databases because many applications
require each row in a table to contain a unique value and sequences provide an easy way to
generate them. The sequence of numeric values is generated in an ascending or descending
order at defined intervals and can be configured to restart when exceeds the maximum
value.
JOINS:
1. INNER JOIN: Returns records that have matching values in both tables.
Syntax: SELECT column_name FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
2. LEFT OUTER JOIN: Returns all records from the left table, and the matched records
from the right table.
Syntax: SELECT column_name FROM table1
LEFT OUTER JOIN table2
ON table1.column_name = table2.column_name;
3. RIGHT OUTER JOIN: Returns all records from the right table, and the matched
records from the left table.
Syntax: SELECT column_name FROM table1
RIGHT OUTER JOIN table2
ON table1.column_name = table2.column_name;
NORMALIZATION:
Normalization is the process of organizing the data and the attributes of a database. It is
performed to reduce the data redundancy in a database and to ensure that data is stored
logically. Data redundancy means having the same data but at multiple places. It is
necessary to remove data redundancy because it causes anomalies in a database which
makes it very hard for a database administrator to maintain it. There are three types of
normal forms that are usually used in relational databases:
CURSORS:
Cursor is a Temporary Memory or Temporary Work Station. It is Allocated by Database
Server at the Time of Performing DML (Data Manipulation Language) operations on Table by
User. Cursors are used to store Database Tables. There are 2 types of Cursors: Implicit
Cursors, and Explicit Cursors. These are:
1. Implicit Cursors:
Implicit Cursors are also known as Default Cursors of Oracle. These Cursors are
allocated by Oracle when the user performs DML operations.
2. Explicit Cursors:
Explicit Cursors are Created by Users whenever the user requires them. Explicit
Cursors are used for Fetching data from Table in Row-By-Row Manner.
FUNCTIONS:
Function in Oracle always accepts parameters, either single or multiple and returns a single
value. The functions are useful in the simplification of our code. Suppose we might have a
complex computation that appears in a number of queries. In such a case, we can build a
function that encapsulates the formula and uses it in each query.
Syntax: CREATE FUNCTION function_name (parameter_list)
RETURN datatype AS
BEGIN
//statements
RETURN value
END;
PROCEDURE:
A stored procedure in SQL is a group of SQL statements that are stored together in a
database. It allows you to pass the same statements multiple times, thereby, enabling
reusability.
TRIGGER:
A trigger is a stored procedure in database which automatically invokes whenever a special
event in the database occurs. For example, a trigger can be invoked when a row is inserted
into a specified table or when certain table columns are being updated.
DEFINITIONS:
Data: Data is recorded things like photo, audio, video etc. Mainly data is in three format int,
char, float.
Database: Database is the collection of interrelated data, for example student records,
employee records etc.
RDBMS: Collection of interrelated data and set of programs (software) that are stored and
used to access stored data.
Instances: Instances are the collection of information stored at a particular moment. The
instances can be changed by certain operations as like insertion, deletion of data. It may be
noted that any search query will not make any kind of changes in the instances.
Schema: Schema is the overall description of the database. The basic structure of how the
data will be stored in the database is called schema.
APPLICATION OF DBMS:
CHARACTERISTICS OF DBMS:
DATA INDEPENDENCE:
Data independence is the ability to modify the schema without affecting the programs and
the application to be rewritten. Data is separated from the programs, so that the changes
made to the data will not affect the program execution and the application.
The main purpose of the three levels of data abstraction is to achieve data independence. If
the database changes and expands over time, it is very important that the changes in one
level should not affect the data at other levels of the database. This would save time and
cost required when changing the database. There are two levels of data independence
based on three levels of abstraction. These are as follows:
Physical Data Independence
Logical Data Independence
DATA REDUNDANCY:
Redundancy in DBMS is having several copies of the same data in the database. Redundancy
may cause inconsistency in data when they are not properly updated. It may also cause an
increase in storage space and cost.
Redundancy in DBMS can be avoided by following the below approaches:
Redundancy in DBMS can be avoided by normalizing the data through
database normalization.
Proper database architecture design can avoid data redundancy.
DATABASE SECURITY:
Database Security means keeping sensitive information safe and to prevent the loss of data.
Security of data base is controlled by Database Administrator (DBA). The following are the
main control measures are used to provide security of data in databases:
1. Authentication
2. Access control
3. Inference control
4. Flow control
5. Applying Statistical Method
6. Encryption
DATA ABSTRACTION:
Data Abstraction is a process of hiding unwanted or irrelevant details from the end user. It
provides a different view and helps in achieving data independence which is used to
enhance the security of data.
The database systems consist of complicated data structures and relations. For users to
access the data easily, these complications are kept hidden, and only the relevant part of
the database is made accessible to the users through data abstraction.
Levels of abstraction for DBMS: In order to make the system efficient, developers use levels
of abstraction that hide irrelevant details from the users. Levels of abstraction simplify
database design. Mainly there are three levels of abstraction for DBMS, which are as
follows:
1. Physical or Internal Level
2. Logical or Conceptual Level
3. View or External Level
DBMS architecture describes the structure and how the users are connected to a specific
database system. It also affects the performance of the database as it helps to design,
develop, implement, and maintain the database management system.
Database management systems are divided into multiple levels of abstraction for proper
functioning. These modules/layers describe the functioning and the design of the DBMS.
Since a database management system is not always directly accessible by the user or an
application, we can maintain it with the help of various architectures based on how the user
is connected to the database. These architectures follow a tier-based classification.
When the layers are increased in the architecture, the level of abstraction also increases,
resulting in an increase in the security and the complexity of the DBMS structure. All these
layers are independent, i.e., any modification performed in a particular layer does not affect
the other layer present in the architecture.
1. Single Tier Architecture (One-Tier Architecture): Single Tier DBMS Architecture is the
most straightforward DBMS architecture. All the DBMS components reside on a
single server or platform, i.e., the database is directly accessible by the end-user.
Because of this direct connection, the DBMS provides a rapid response, due to which
programmers widely use this architecture to enhance the local application.
In this structure, any modifications done by the client are reflected directly in the
database, and all the processing is done on a single server. Also, no network
connection is required to perform actions on the database. This database
management system is also known as the local database system.
Single Tier DBMS Architecture is used whenever:
The data isn't changed frequently.
No multiple users are accessing the database system.
We need a direct and simple way to modify or access the database for
application development.
2. Two-Tier Architecture: The Two-Tier DBMS Architecture is used when we wish to
access the DBMS with the help of an application. Client-side applications can access
the database server directly with the help of API calls, making the application
independent of the database in terms of operation, design, and programming.
The main advantages of having a two-tier architecture over a single tier are:
Multiple users can use it at the same time. Hence, it can be used in an
organization.
It has high processing ability as the database functionality is handled by the
server alone.
Faster access to the database due to the direct connection and improved
performance.
Because of the two independent layers, it's easier to maintain.
1. Application Programmers – They are the developers who interact with the database
by means of DML queries. These DML queries are written in the application
programs like C, C++, JAVA, Pascal, etc. These queries are converted into object code
to communicate with the database.
2. Sophisticated Users – They are database developers, who write SQL queries to
select/insert/delete/update data. They do not use any application or programs to
request the database.
3. Specialized Users – These are also sophisticated users, but they write special
database application programs. They are the developers who develop the complex
programs to the requirement.
4. Stand-alone Users – These users will have a stand-alone database for their personal
use. These kinds of the database will have readymade database packages which will
have menus and graphical interfaces.
5. Native Users – These are the users who use the existing application to interact with
the database to fulfil their requests.
DATABASE ADMINISTRATORS:
The administration and maintenance of the database are taken care of by the database
Administrator. The role of DBA is:
1. Installing and upgrading the DBMS Servers: DBA is responsible for installing a new
DBMS server for the new projects. He is also responsible for upgrading these servers
as there are new versions that come into the market or requirement.
2. Design and implementation: Designing the database and implementing is also DBA’s
responsibility. He should be able to decide on proper memory management, file
organizations, error handling, log maintenance, etc for the database.
3. Performance tuning: Since the database is huge and it will have lots of tables, data,
constraints, and indices, there will be variations in the performance from time to
time. It is the responsibility of the DBA to tune the database performance.
4. Migration: Sometimes, users using oracle would like to shift to SQL server or
Netezza. It is the responsibility of DBA to make sure that migration happens without
any failure, and there is no data loss.
5. Backup and Recovery: Proper backup and recovery programs needs to be developed
by DBA and has to be maintained by him. This is one of the main responsibilities of
DBA. Data/objects should be backed up regularly so that if there is any crash, it
should be recovered without much effort and data loss.
6. Security: DBA is responsible for creating various database users and roles, and giving
them different levels of access rights.
7. Documentation: DBA should be properly documenting all his activities so that if he
quits or any new DBA comes in, he should be able to understand the database
without any effort.
DATABASE STRUCTURE:
The database system is divided into three components: Query Processor, Storage Manager,
and Disk Storage. These are explained as following below.
1. Query Processor: It interprets the requests (queries) received from end user
via an application program into instructions.
2. Storage Manager: Storage Manager is a program that provides an interface
between the data stored in the database and the queries received. It is also
known as Database Control System.
3. Disk Storage: It contains the following components:
1. Data Files: It stores the data.
2. Data Dictionary: It contains the information about the structure of any
database object. It is the repository of information that governs the
metadata.
3. Indices: It provides faster retrieval of data item.
DATABASE BACKUP, RECOVERY AND
PRIVILEGES:
1. Backup: Backup refers to storing a copy of original data which can be used in case of
data loss. Backup is considered as one of the approaches to data protection.
Important data of the organization needs to be kept in backup efficiently for
protecting valuable data. Backup can be achieved by storing a copy of the original
data separately or in a database on storage devices. There are various types of
backups are available like full backup, incremental backup, Local backup, mirror
backup, etc. An example of a Backup can be SnapManager which makes a backup of
everything in the database.
2. Recovery: Recovery refers to restoring lost data by following some processes. When
a database fails due to any reason then there is a chance of data loss, so in that case
recovery process helps in improve the reliability of the database. An example of
Recover can be SnapManager which recovers the data from the last transaction.
There are two methods that are primarily used for database recovery. These are:
1. Log based recovery: In log-based recovery, logs of all database transactions
are stored in a secure area so that in case of a system failure, the database
can recover the data. All log information, such as the time of the transaction,
its data etc. should be stored before the transaction is executed.
2. Shadow paging: In shadow paging, after the transaction is completed its data
is automatically stored for safekeeping. So, if the system crashes in the
middle of a transaction, changes made by it will not be reflected in the
database.
3. Privilege: A privilege is permission to execute one particular type of SQL statement
or access a second persons’ object. Database privilege controls the use of computing
resources. Database privilege does not apply to the Database administrator of the
database.
DATABASE TRANSACTION:
A transaction is a logical unit of work that accesses and updates the contents of a database.
Read and write operations are used by transactions to access data. A transaction has several
states:
1. Active State: Every transaction starts out in the active state. The transaction is
currently being carried out in this state.
2. Partially Committed State: A transaction has reached this state when it completes all
operations but the data has not been saved to the database.
3. Failed State: The transaction is considered to be in the failed state if any of the
database recovery system’s checks fail.
4. Committed State: If a transaction completes its final operation successfully, it is
considered to be committed. In this state, all of the changes are written to memory
and as a result, saved on the database system permanently.
5. Aborted State: If any of the tests fail, the transaction is said to go to a failed state.
Upon entering this state, the database recovery system attempts to bring the
database to the previous consistent state (committed state). If this doesn’t happen
then the transaction would be rolled back or aborted so as to bring the database
back to a consistent state. Once it has been aborted, the database recovery module
will either kill the transaction or re-start the transaction.
6. Terminated State: If there is no rollback and the transaction is in the committed
state, the system is consistent and ready for a new transaction, while the old one is
terminated.
ACID Properties in DBMS are of extreme significance as they ensure accuracy, completeness,
and data integrity. Everyday occurrences such as using computer systems to buy things
would be difficult without these ACID properties, and the possibility for errors would be
enormous. ACID properties are followed before and after a transaction in order to preserve
database consistency.
1. Atomicity: The term atomicity is the ACID Property in DBMS that refers to the fact
that the data is kept atomic. It means that if any operation on the data is conducted,
it should either be executed completely, or it not at all. It also implies that the
operation should not be interrupted or just half completed. If any of the operations
aren’t completed fully, the transaction gets aborted. Atomicity is often referred to as
the ‘all or nothing’ rule.
2. Consistency: This ACID Property is used after each transaction; consistency is
checked to ensure nothing has gone wrong.
3. Isolation: Isolation is defined as a state of separation. Isolation is an ACID Property in
DBMS where no data from one database should impact the other and where many
transactions can take place at the same time. When two or more transactions occur
at the same time in the case of transactions, consistency should be maintained.
4. Durability: The ACID Property durability in DBMS refers to the fact that if an
operation is completed successfully, the database remains permanent in the disk.
The database’s durability should be such that even if the system fails or crashes, the
database will survive.
EF CODD’S RULES:
Rule 0 − Foundation rule: Any relational database management system that is propounded
to be RDBMS or advocated to be a RDBMS should be able to manage the stored data in its
entirety through its relational capabilities.
Rule 1 − Rule of Information: Relational Databases should store the data in the form of
relations. Tables are relations in Relational Database Management Systems. Be it any user
defined data or meta-data, it is important to store the value as an entity in the table cells.
Rule 2 − Rule of Guaranteed Access: The use of pointers to access data logically is strictly
forbidden. Every data entity which is atomic in nature should be accessed logically by using
a right combination of the name of table, primary key represented by a specific row value
and column name represented by attribute value.
Rule 3 − Rule of Systematic Null Value Support: Null values are completely supported in
relational databases. They should be uniformly considered as ‘missing information’. Null
values are independent of any data type. They should not be mistaken for blanks or zeroes
or empty strings. Null values can also be interpreted as ‘inapplicable data’ or ‘unknown
information.’
Rule 4 − Rule of Active and online relational Catalogue: The active online catalogue that
stores the metadata is called ‘Data dictionary’. The so-called data dictionary is accessible
only by authored users who have the required privileges and the query languages used for
accessing the database should be used for accessing the data of data dictionary.
Rule 5 − Rule of Comprehensive Data Sub-language: A single robust language should be able
to define integrity constraints, views, data manipulations, transactions and authorizations.
Rule 6 − Rule of Updating Views: Views should reflect the updates of their respective base
tables and vice versa. A view is a logical table which shows restricted data. Views generally
make the data readable but not modifiable. Views help in data abstraction.
Rule 7 − Rule of Set level insertion, update and deletion: A single operation should be
sufficient to retrieve, insert, update and delete the data.
Rule 8 − Rule of Physical Data Independence: Batch and end user operations are logically
separated from physical storage and respective access methods.
Rule 9 − Rule of Logical Data Independence: Batch and end users can change the database
schema without having to recreate it or recreate the applications built upon it.
Rule 12 − Rule of Non-Subversion: Any row should obey the security and integrity
constraints imposed. No special privileges are applicable.
BLOCK STRUCTURE OF PL/SQL:
DATATYPES IN PL/SQL:
EXCEPTION HANDLING:
An exception is an error which disrupts the normal flow of program instructions. PL/SQL
provides us the exception block which raises the exception thus helping the programmer to
find out the fault and resolve it.
Syntax: DECLARE
declarations section;
BEGIN
executable command(s);
EXCEPTION
WHEN exception1 THEN
statement1;
WHEN exception2 THEN
statement2;
[WHEN others THEN]
/* default exception handling code */
END;
COMPARISONS: