

















































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















































































This is the first of many practices in this course. The solutions (if you require them) can be found at the end of this practice. Practices are intended to cover most of the topics that are presented in the corresponding lesson.
Starting Oracle SQL Developer
Creating a New Oracle SQL Developer Database Connection
To create a new database connection, in the Connections Navigator, right-click Connections. Select New Connection from the menu. The New/Select Database Connection dialog box appears.
Create a database connection using the following information:
a) Connection Name: myconnection b) Username: ora c) Password: ora d) Hostname: localhost e) Port: 1521 f) SID: ORCL
Ensure that you select the Save Password check box.
Testing and Connecting Using the Oracle SQL Developer Database Connection
Test the new connection.
If the status is Success, connect to the database using this new connection.
Browsing the Tables in the Connections Navigator
In the Connections Navigator, view the objects available to you in the Tables node. Verify that the following tables are present: COUNTRIES DEPARTMENTS EMPLOYEES JOB_GRADES JOB_HISTORY JOBS LOCATIONS REGIONS
Browse the structure of the EMPLOYEES table.
View the data of the DEPARTMENTS table.
Starting Oracle SQL Developer
a) Double-click the SQL Developer desktop icon.
The SQL Developer Interface appears.
Creating a New Oracle SQL Developer Database Connection
Testing and Connecting Using the Oracle SQL Developer Database Connection
Test the new connection.
If the status is Success, connect to the database using this new connection.
When you create a connection, a SQL Worksheet for that connection opens automatically.
Browsing the Tables in the Connections Navigator
In this practice, you write simple SELECT queries. The queries cover most of the SELECT clauses and operations that you learned in this lesson.
Your first task is to determine the structure of the DEPARTMENTS table and its contents.
Determine the structure of the EMPLOYEES table.
The HR department wants a query to display the last name, job ID, hire date, and employee ID for each employee, with the employee ID appearing first. Provide an alias STARTDATE for the HIRE_DATE column. Save your SQL statement to a file named lab_01_05.sql so that you can dispatch this file to the HR department.
Note: After you have executed the query, make sure that you do not enter your next query in the same worksheet. Open a new worksheet.
Part 3
If you have time, complete the following exercises:
Part 1
Test your knowledge:
SELECT last_name, job_id, salary AS Sal FROM employees;
True /False
SELECT * FROM job_grades;
True /False
SELECT employee_id, last_name sal x 12 ANNUAL SALARY FROM employees;
The EMPLOYEES table does not contain a column called sal. The column is called SALARY.
*The multiplication operator is , not x, as shown in line 2.
The ANNUAL SALARY alias cannot include spaces. The alias should read ANNUAL_SALARY or should be enclosed within double quotation marks.
A comma is missing after the LAST_NAME column.
Part 2
You have been hired as a SQL programmer for Acme Corporation. Your first task is to create some reports based on data from the Human Resources tables.
a. To determine the DEPARTMENTS table structure: DESCRIBE departments
b. To view the data contained in the DEPARTMENTS table: SELECT * FROM departments;
DESCRIBE employees
The HR department wants a query to display the last name, job ID, hire date, and employee ID for each employee, with the employee ID appearing first. Provide an alias STARTDATE for the HIRE_DATE column. Save your SQL statement to a file named lab_01_05.sql so that you can dispatch this file to the HR department. SELECT employee_id, last_name, job_id, hire_date StartDate FROM employees;
SELECT employee_id, last_name, job_id, hire_date StartDate FROM employees;
Part 3
If you have time, complete the following exercises:
The HR department wants more descriptive column headings for its report on employees. Copy the statement from lab_01_05.sql to a new SQL Worksheet. Name the column headings Emp #, Employee, Job, and Hire Date, respectively. Then run the query again. SELECT employee_id "Emp #", last_name "Employee", job_id "Job", hire_date "Hire Date" FROM employees;
The HR department has requested a report of all employees and their job IDs. Display the last name concatenated with the job ID (separated by a comma and space) and name the column Employee and Title. SELECT last_name||', '||job_id "Employee and Title" FROM employees;
In this practice, you build more reports, including statements that use the WHERE clause and the ORDER BY clause. You make the SQL statements more reusable and generic by including the ampersand substitution.
The HR department needs your assistance in creating some queries.
Because of budget issues, the HR department needs a report that displays the last name and salary of employees who earn more than $12,000. Save your SQL statement as a file named lab_02_01.sql. Run your query.
Open a new SQL Worksheet. Create a report that displays the last name and department number for employee number 176. Run the query.
The HR department needs to find high-salary and low-salary employees. Modify lab_02_01.sql to display the last name and salary for any employee whose salary is not in the range of $5,000 to $12,000. Save your SQL statement as lab_02_03.sql.
Create a report to display the last name, job ID, and hire date for employees with the last names of Matos and Taylor. Order the query in ascending order by the hire date.