oracle 11g database development lab2. chapter- 2 these commands, which could be issued from...

21
Oracle 11g DATABASE DEVELOPMENT LAB2

Upload: aubrey-wilkinson

Post on 13-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Oracle 11g DATABASE DEVELOPMENT

LAB2

Page 2: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 These commands, which

could be issued from SQL*Plus or SQL Developer,

will make it possible to log on as users HR and OE using the passwords HR and OE:

alter user hr account unlock identified by hr;

alter user oe account unlock identified by oe;.

Now login to sqlplus using the user name and password

Hr Hr

Page 3: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 Arithmetic expression to calculate number of

days worked.

Page 4: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .

Use of the concatenation and arithmetic operators

Page 5: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2

.

Use of column and expression aliases

Page 6: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .

Use of the AS keyword to specify column aliases

Page 7: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .

Null values in the Commission_Pct column

Page 8: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .

Null arithmetic always returns a null value.

Page 9: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 . Question 1: It was demonstrated earlier how the number of days for which

staff were employed in a job could be calculated. For how many years were staff employed while fulfilling these job roles and what were their EMPLOYEE_ID, JOB_ID, START_DATE, and END_DATE values? Alias the expression column in your query with the alias Years Employed. Assume that a year consists of 365.25 days.

select employee_id, job_id, start_date, end_date, ((end_date-start_date) + 1)/365.25 "Years Employed" from job_history;

Page 10: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .

Page 11: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .

select 'The Job Id for the '||job_title||'''s job is: '||job_id AS "Job Description“ from jobs;

Page 12: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .

Character column-based WHERE clause

Page 13: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .Equivalence of conditional

expressions

Page 14: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 Statement 1: select employee_id from job_history where start_date = end_date; Statement 2: select employee_id from job_history where start_date = '01-JAN-2001'; Statement 3: select employee_id from job_history where start_date = '01-JAN-01'; Statement 4: select employee_id from job_history where start_date = '01-JAN-99';.

Page 15: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .

Using theWHERE clausewith numericexpressions

Page 16: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .Conditions basedon the equalityoperator

Page 17: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .Conditions basedon the inequalityoperators

Page 18: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2select last_name from employees

where salary between 3400 and 4000;

select last_name from employees

where salary >= 3400

and salary <= 4000;

select first_name, hire_date from employees

where hire_date between '24-JUL-1994' and '07-JUN-1996';

select first_name, hire_date from employees

where '24-JUL-1994' between hire_date+30 and '07-JUN-1996';.

Page 19: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2select last_name from employees

where salary in (1000,4000,6000);

select last_name from employees

where salary = 1000

OR salary = 4000

OR salary = 6000;

select last_name from employees

where last_name in ('King','Garbharran','Ramklass');

select last_name from employees

where hire_date in ('01-JAN-1998','01-DEC-1999');

.

Page 20: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2select first_name from employees

where first_name like 'A;'%where first_name like;'%'

where last_name like 'King;'where last_name = 'King;'

.

Pattern Comparison with the LIKE Operator

Page 21: Oracle 11g DATABASE DEVELOPMENT LAB2. Chapter- 2  These commands, which could be issued from SQL*Plus or SQL Developer,  will make it possible to log

Chapter- 2 .