Database Assignment-2
Database Assignment-2
SQL Statements
1) Select Statement
2) Delete Statement:- DELETE FROM table_name
WHERE some_column=some_value
3) Commit
4) Rollback
7) Modify:-
10)
SELECT Date
Intersect
FROM Internet_Sales
11)
12)
13)
Where
Like
Oracle allows multiple triggers with the same trigger timing and
trigger event to be defined on a table; however, these triggers are not
guaranteed to execute in any specific order. Triggers can be defined as
row triggers or statement triggers. Statement triggers are fired once
for each triggering statement regardless of the number of rows in a
table affected by the triggering statement. For example if a DELETE
statement deletes several rows from a table, a statement trigger is only
fired once.
The execution model for Oracle triggers is transactional. All actions
performed as a result of the triggering statement, including the actions
performed by fired triggers, must all succeed; otherwise, they are
rolled back.
Procedure heading: =
Procedure definition: =
The name that you give to the procedure that you are declaring or
defining.
Stored Procedures
Stored procedures provide a powerful way to code application logic
that can be stored on the server. MySQL and Oracle both use stored
procedures and functions. Stored functions are similar to procedures,
except that a function returns a value to the environment in which it is
called. In MySQL, stored procedures and functions are collectively
called routines.
The following sections compare stored procedures in MySQL and
Oracle:
REPLACE Statement
DO Statement
Oracle does not have any built-in SQL statements that supports the
purposes of the MySQL REPLACE statement. To convert this
statement to Oracle, an emulated function using both the INSERT and
UPDATE statements has to be created. An attempt is first made to
place the data into the table using the INSERT statement; and if this
fails, the data in the table is then updated using the UPDATE
statement.
DO Statement
As its name implies, the DO statement in MySQL does something but
does not return anything; specifically, it executes the commadelimited list of expressions specified as its parameters. The DO
statement is converted to a SELECT expr1 [, expr2,] INTO
FROM DUAL statement in Oracle.
Compound DECLARE Statement
MySQL uses the DECLARE statement to declare local variables in
stored procedures. PL/SQL does not allow multiple declarations; each
declaration must be made separately. To convert compound
DECLARE statements into functionally equivalent PL/SQL code,
each MySQL multiple declaration statement should be converted into
logically equivalent separate statements, one for each declaration.
For example, consider the following MySQL simple declaration and
multiple declaration statements:
/* Simple declaration */
DECLARE a INT;
/* Compound declaration */
DECLARE a, b INT DEFAULT 5;
The PL/SQL functionally equivalent statements are:
/* Simple declaration */
a INT;
/* Multiple declarations */
a INT := 5;
b INT := 5;
Concurrency Control
Definition
Concurrency control is a database management systems (DBMS)
concept that is used to address conflicts with the simultaneous
accessing or altering of data that can occur with a multi-user system.
Concurrency control, when applied to a DBMS, is meant to
coordinate simultaneous transactions while preserving data integrity.
[1] The Concurrency is about to control the multiuser access of
Database
Illustrative Example
To illustrate the concept of concurrency control, consider two
travellers who go to electronic railway reservation counter at the same
time to purchase a train ticket to the same destination on the same
train. There's only one seat left in the coach, but without concurrency
control, it's possible that both travelers will end up purchasing a ticket
for that one seat. However, with concurrency control, the database
wouldn't allow this to happen. Both travellers would still be able to
access the train seating database, but concurrency control would
preserve data accuracy and allow only one traveler to purchase the
seat.
This example also illustrates the importance of addressing this issue
in a multi-user database. Obviously, one could quickly run into
problems with the inaccurate data that can result from several
transactions occurring simultaneously and writing over each other.
The following section provides strategies for implementing
concurrency control.
i)
Transaction processing
ii)
Optimization