Relational Database Management System (RDBMS) : Payroll
Relational Database Management System (RDBMS) : Payroll
Payroll
Employee Number
Project Number
Emp_info Project
ORACLE TOOLS
1. SQL * PLUS: for writing command line SQL queries to work with
database objects.
2. PL/ SQL: oracle’s extension, It is a procedural language
3. Query: creating SQL query using graphical environment. It allow to
write the DDL, DML, and DCL statements.
4. Developer : used for developing database applications
- Form Builder: It is useful to create graphical forms and menu.
- Report Builder: To create reports in different formats, save the
reports, print the data.
- Developer – Graphics Builder – it is used to create the graphical
charts like, Bar Charts, Pie Charts etc. based on data
ORACLE TOOLS
6. Oracle Web Application Server: A tool for creating a web site that
allows user to access oracle database through web pages
ORACLE DBA
• installing the oracle database, managing the day-to day needs of the
complex database, and running the system at a peal performance
• performs software maintenance, resource management, data
administration, database tuning, and troubleshooting, data security and
backup and recovery.
ORACLE DBA
Basic duties or Role or Responsibilities of the DBA:
1. Installing of new hardware and software
2. Configuration of hardware and software with the system
administration
3. Security administration
4. Performance tuning & monitoring:
5. Backup and Recovery
6. Routine schedule maintenance
7. Troubleshooting
8. Failure Recovery
9. Crate,Alter and remove database, data users and Roles
10. Grant and restrict access rights
SQL * PLUS
Disk3
System Accounting Purchasing
Table space Table space Table space Acct.
datafile3
Disk1 Disk2 Disk3
Pur.
System Acct. Acct. datafile1
datafile1 datafile1 datafile2
SCHEMA OBJECTS
• A schema is a collection of objects
1. TABLE : which consists of a table name and rows and column of data
1 G. Gore 01-JUN-07
• SELECT
• INSERT , UPDATE, DELETE,
• CREATE, ALTER, DROP, RENAME TRUNCATE
• GRANT, REVOKE
Types of SQL statement
• The datatype specifies the type of data that will be stored in that
attribute . ,The wrong kind of data prevented from being stored in
the attribute
• help optimize storage space
VARCHAR2 Data Types
G . G O R E
CHAR Data Types
G . G O R E
NUMBER Data Types
• The scale is the total number of digits to the right side of the
decimal point
• The precision can range from 1 to 38. the scale can range from
---- 84 to 127
• 12000.50 Scale
12000.50
Precision
NUMBER Data Types
• Table names and column names must begin with a letter and can
be 1 to 30 character long
e.g.
CREATE TABLE EMP_INFO_00 (
EMP_ID NUMBER,
NAME varchar2(25),
ADDRESS VARCHAR2(50),
BIRTH_DATE DATE,
GENDER CHAR(1),
SALARY NUMBER(9,2) );
SQL and SQL* PLUS
SQL SQL * PLUS
A Language An environment
• The Syntax is
• INSERT INTO TABLE_NAME VALUES(&COLUMN1,&COLUMN2);
2. Explicit Method : In the explicit method, the value null is used
as a value for numeric column, and the empty string(‘ ‘) is used
for date or character column.
• The from clause specifies the large table containing the row
• SELECT ALL/DISTINCT/*/COLUMN_NAMES
FROM TABLE_NAME
[WHERE CONITION]
[GROUP BY grouping columns]
[HAVING search condition]
[ORDER BY sort specification] ;
RETRIVING DATA FROM A TABLE : (SELECT COMMAND) –
DATA QUERY LANGUAGE
• The WHERE clause tells SQL to include only certain rows of data
in the query results. A search condition is used to specify the
desired rows.
• The syntax is
SELECT * FROM TABLE_NAME;
e.g. SELECT * FROM EMP_00;
• The syntax is
SELECT COLUMN1,COLUMN2 FROM TABLE_NAME;
e.g. SELECT emp_name,emp_id FROM EMP_00;
• The syntax is
SELECT DISTINCT COLUMN1 FROM TABLE_NAME;
e.g. SELECT DISTINCT DESIGNATION FROM EMP_00;
• The syntax is
SELECT COLUMN [AS] ‘ALIAS NAME’ FROM TABLE_NAME;
• The Syntax is
SELECT columnlist FROM table_name
[ WHERE condition(s) ] [ ORDER BY column/expression [ASC]/DESC;
• e.g. List out only those employee’s whose salary is more than
10000
SELECT empname, salary FROM employs WHERE salary > 10000
SEARCH CONDITIONS
• conditions that allow you to specify many different kinds of queries efficiently
and naturally
Syntax
SELECT * from table_name
WHERE column operator value [and/or column operator value];
COMAPRISION TEST
• Tests whether the value of an expression falls within a specified range of values.
• NOT operator are used to negate the result of any criteria check mode. The
negate version of the range test (NOT BETWEEN) checks for values that fall
outside the range.
• used to check whether a data value matches one of a list target values.
• List all the employee name whose salaries are not exactly 8000, 10000, and 12000;
PATTERN MATCHING TEST (LIKE operator)
• When character data are to be matched with some pattern, the LIKE operator is
used
• The pattern matching test LIKE , checks to se whether the data value in a column
matches a specified pattern.
• List all the employee name whose salaries are not exactly 8000, 10000, and 12000;
PATTERN MATCHING TEST (LIKE operator)
• we want to see the employees name whose name ends with RAM
characters
• For example “T_M” represents the letter “T” followed by any single character,
followed by the letter “M”, and would retrieve the records that include the words
TIM, TOM, or T3M.
• How do you look for a value that has a wild card character
embedded in it?
• e.g. Find product whose product id’s start with the four letters “A
%BC”
• The first % means the column value starts with any characters in
the beginning. The second % means that the value ends with any
character. The character /_ means that there is a _character in the
value. The / is used as the escape character which changes the
meanings of _ from a wild card to the underscore
NULL VALUE TEST (IS NULL) :
• the select clause in grouped query can fetch only the grouping
columns & aggregate function.
GROUPPING DATA: (GROUP BY CLAUSE)
• SELECT COLUMN,GROUPFUNCTION(COLUMN)
FROM TABLE_NAME
[WHERE Condition]
GROUP BY column/expression
[ORDER BY column/expression [ASC]/DESC];
10 2
20 3
30 4
GROUP SEARCH CONDITION: HAVING CLAUSE
• The HAVING clause can be used to select and reject row groups.
The GROUP function works on each group. and HAVING clause
keeps the group that match the group function.
• A query, which retrieves data from more than one table using a
single select statement, is called as a Multi – Table Query or JOIN
query.
• . the join condition combines a row in one table with a row from
another table based on the same value in the common attributes
• Following types of join are available in oracle
Equi – Join
Non equi –Join
Outer – Join
Self – Join.
Equi – Join or inner join
• The syntax is
SELECT columnlist FROM table_names WHERE join condition;
• e.g. display employee name and corresponding departments of
all employees ;
• SELECT employee.emp_name,dept.dept_name
FROM employee,dept
WHERE employee.dept_no = dept.dept_no;
Equi – Join
e.g. display the name and job of each employee and the number
and name of the department in which the employee works
SELECT e.emp_name,d.dept_name,s.desg_name
FROM employee e, dept d, desgn_mst s
WHERE e.dept_no=d.dept_no and e.desg_code=s.des_code;
NON EQUI – JOIN
1 G. GORE 4000
2 K. KALE 12000
NON EQUI – JOIN
EMP_NAME LEVEL_NO
G. GORE 1
K. KALE 3
S. SAWLE 2
P. PANDHRE 2
SELF JOIN :
1 G GORE 10 15000
2 K KALE 20 1 16000
Self – Join
• 1. When a table joined to itself, two copies of the same table are
• create
• UNION
• INTERSECT
• MINUS
STUDENT WORKER
STUD_ID STUD_NAME WORKER_ID WORKER_NAME
1 R. RAM 1 R RAM
2 S SHYAM 2 C CHAVAN
3 P PANDURANG 3 P PANDURANG
UNION
STUD_ID STUD_NAME
1 R. RAM
2 S SHYAM
2 C. CHAVAN
UNION Restriction
1 R. RAM
1 R RAM
2 S. SHYAM
2 C. CHAVAN
INTERSECT
STUD_ID STUD_NAME
1 R. RAM
2 P PANDURANG
MINUS (DIFFERENCE)
• Minus operation fetch only those records that are available in the
first SELECT statement and are not available in the second
SELECT statement
STUD_ID STUD_NAME
3 S SHYAM
SUBQUERIES
• Subqueries are nested queries in which the result from one query
is utilized in another query.
• Subquery combines two query statements into a single query
statement, where the result of one query depends on the result
of other query
• A single row subquery is one that returns one row from the inner
select statement.
• The syntax is
SELECT columnlist
FROM table_name
WHERE column_name operator
(SELECT columnlist from tablename WHERE condition);
Rules for SUBQUERIES
• UPDATE tablename
SET (columnnames)=
(SELECT columnlist FROM tablename WHERE sub-uery) WHERE
condition;
• e,g, Increase the salary of all employees by 1000 whose
designation is same as employee P PATIL designation
UPDATE employee
SET SALARY =SALARY+1000 WHERE desg_code=
(SELECT desg_code FROM employee WHERE emp_name=’P PATIL’)
DELETE using a sub-query.
UPDATE employee
SET SALARY =SALARY+1000 WHERE desg_code=
(SELECT desg_code FROM employee WHERE emp_name=’P PATIL’)
Manipualtion of date (Date functions)
• MONTHS_BETWEEN ( DATE1,DATE2) :
If you want to know how many months fall between month x and
month y
Consider in PROJECT table there are START_DATE and END_DATE
columns
SELECT TASK, START_DATE, END_DATE,
MOTHS_BETWEEN(END_DATE,START_DATE) “Duration” FROM
PROJECT;
ADD_MONTHS(DATE , NUMBER) :
• returns the date of the last day of the month that contains date
END_DATE LAST_DAY
(END_DATE)
01-APR-05 30-APR-05
NEXT_DAY( DATE, CAHRACTER)
• Finds the name of the first week that is equal to or later than
another specified date
START_DATE LAST_DAY
(END_DATE)
SYSDATE ( )
SYSDATE
28-MAR-06
CHARACTER FUNCTIONS
INITCAP returns char, with the first letter of each word in uppercase,
all other letters in lower case
Removes all the characters present to the left of string1, which are
mentioned in string2
SELECT LTRIM(‘XXXORACLE’,’X’) FROM DUAL;
The result is
---------------------------------
ORACLE
RTRIM (string1, string2) :
Removes all the characters present to the right of string1 which are
mentioned in string 2
SELECT RTRIM(‘ORACLEXXX’,’X’) FROM DUAL;
The result is
---------------------------------
ORACLE
NUMERIC FUNCTIONS
ABS(NUMBER)
• Numeric function takes numeric value input and return numeric
values.
return 9
MOD (Num1, Num2 ) :
return 1
ROUND( Num1, Num2) :
return 1027
SQRT ( Number ) :
Share Mode Lock : used when transaction wants to read data from
database. The updation is not allowed.
Update OK
OK Update
Orders Locked for B Products
Locked for A
Update OK
order