Download Exam Review - Section 8 Lesson 2 - S

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Configurable Network Computing wikipedia , lookup

Transcript
Database Programming - Review
Answer each of the following questions:
1. What is the most efficient way to display all of the columns and rows in the table
shown below?
DEPARTMENTS
DEPARTMENT_ID
DEPARTMENT_NAME
Description
10
Administration
Operations for corporation
20
Marketing
Advertising, PR and other
promations
2. Which clause in a SELECT statement retrieves information using projection?
3. Which clause in a SELECT statement retrieves information using selection?
4. Which of the following are TRUE about SQL statements?
____a. SELECT or select can be used to name columns
____b. All keywords such as ORDER BY and DESCENDING can be
abbreviated. For example ORDER BY can be abbreviated as ORD BY, and
DESCENDING can be abbreviated as DESC.
____c. Separate lines and indents organize code so it executes faster
____d. The order of the clauses in a SELECT statement doesn't matter as long
as SELECT and FROM and WHERE are included.
5. The SELECT * statement is used to:
____a. Show all the column names in the table
____b. View all the data in a table
____c. Update information in a table
____d. Show the table structure and data types.
Oracle Academy
1
Database Programming - Review
6. Write a statement that includes an example of “SELECTION.”
7. A relational database is made up of _______which have horizontal ___
_______and vertical __
The intersection of a horizontal and a vertical ___________is called a _______
8. Which of the following are TRUE about Relational Databases.
____a. Entries in columns are single-valued.
____b. Entries in columns can be of more than one kind of data (datatype)
____c. As long as a column has a primary key, identical rows can exist in the
same table
____d. The order of the rows stored in a database table is insignificant
____e. When naming columns in a table with the same name, the table names
need aliases
9. Give an example of a SQL command that belongs to each category below:
____________Data Manipulation Language
____________Data Definition Language
____________Transaction Control
____________Data Control Language
10. The System Development Life Cycle is a process similar to:
_____a. Assembling a model of an airplane
_____b. Designing and building a new type of satellite
_____e. Learning how to use a computer
_____f. Watching a puppy grow up to a dog
11. Write the code that would show the structure of DJ On Demand, d_cds table.
Then show the code that would select all data from the DEPT table.
12. Create a query to display unique client numbers from the DJ On Demand
d_clients table.
Oracle Academy
2
Database Programming - Review
13. Create a query to display the name, job id, hire date, and employee id for each
Oracle employee, with employee id appearing last.
14. Write a SELECT statement that will return the first name, last name, salary and
the salary with a 5% bonus and $100.00 added (4 columns).
15. Which of the following SELECT statements could represent a transaction of
making a car payment with a late fee of 0.1% on unpaid balance.
a. SELECT unpaid balance *.001 - payment AS "Transaction"
b. SELECT unpaid balance - payment * .001 AS "Transaction"
c. SELECT balance* 0.001 = (remaining balance - payment) AS "Transaction"
16. Using the Oracle database EMPLOYEES table, write a SELECT statement to
produce the following output
"Ernst has a monthly salary of 6000 dollars
17. Which of the following is TRUE about the following SELECT statement:
SELECT DISTINCT color, style
FROM shirts
_____ a. Blue shirts will only be listed once
_____ b. All distinct combinations of blue shirts and styles will be listed
_____ c. The DISTINCT keyword only applies to color
_____d. Distinct color and style combinations can be listed more than once or
each style.
18. Create a query to display the name and salary of the Global Fast Foods
employees earning more than $7.00 an hour.
Oracle Academy
3
Database Programming - Review
19. Display the name and birthdate of every Global Fast Foods employee who was
born in1980;
20. Display the names of all Global Fast Foods employees where the second letter
of their name is an "o"
21. For each employee in the Oracle database, display the employee last name and
calculate the number of months between today and the date the employee was
hired. Label the column MONTHS_WORKED. Order your results by the number of
months employed. Round the number of months up to the closest whole number.
22. Each SQL statement below that queries the Global Fast Foods database has errors.
Correct them and execute the query in HTML DB.
a. SELECT first name, last name AS Global Staff
FROM f_staff;
b. SELECT first_name |" " | last_name AS 'DJ On Demand Clients'
FROM d_clients;
c. SELECT DISTINCT f_order_lines, DISTINCT order_number
FROM quantity;
d. SELECT order number, address, city, state
FROM f_orders;
23. Which expression below will produce the largest value?
a. SELECT salary* (6 + 100)/2
b. SELECT salary*6 + 100/2
c. SELECT salary + (100/2)*6
d. SELECT salary+6*100/2
Oracle Academy
4
Database Programming - Review
24. Which SELECT statement will produce the following results?
Oldest
"The 1997 recording in our database is The Celebrants Live in Concert"
a. SELECT ||The year recording in our database is ' || title AS "Oldest"
FROM d_cds WHERE year=1997;
b. SELECT "The 1997 recording in our database is ||title AS "Oldest"
FROM d_cds WHERE year=1997;
c. SELECT ' ||The year recording in our database is|| ' title AS "Oldest"
FROM d_cds WHERE year=1997;
d. SELECT 'The '||year||' recording in our database is ' ||title AS "Oldest"
FROM d_cds WHERE year=1997;
25. Which WHERE clauses are invalid? Mark an N for not valid.
____a, WHERE quantity <> NULL;
____b. WHERE quantity = NULL;
____c. WHERE quantity IS NULL;
____d. WHERE quantity != NULL;
26. Write a query that produces the following for each Global Fast Food employee:
<employee last name> earns<salary> monthly but wants <10% raise>. Label the
column Promotion Salary.
27. Display the last name, hire date, and day of the week on which the Oracle
employees started. Label the column DAY. Order the results by the day of the week
starting with Monday.
Oracle Academy
5
Database Programming - Review
28. Which venues did DJ On Demand play that were not in Private Homes and not in
Hotels?
29. In the following statement, how will the column data be displayed?
SELECT department_id, last_name, manager_id
FROM employees
WHERE employee_id < 125
ORDER BY department_id DESC, last_name
30. Starting with the string 'Oracle Internet Academy', pad the string to
createOracle****Internet****Academy****
31. Use the DUAL table to process the following numbers:
845.559 - round to two decimal place
30695.348 - round to zero decimal places
30695.348 - round to -2 decimal places
2.3454 - truncate the 54 from the decimal place
32. Write the code to display the number of months between your birthday this year and
your birthday next year?
33. What is the last day of the month for November 2005?
Oracle Academy
6
Database Programming - Review
34. Your term paper is due one month from today, What day do need to have your
paper completed?
35. Replace every 'e' in "For your eyes only" with an @
36.
Convert your birthday to the following formats:
a. January First, Two Thousand Eighty
b. January 1st
37. Convert SEPTEMBER302005 to the default date format using the fx format model.
38. You want to be able to replace all null values in the title column of your CD
collection table with "need to buy". Write the code that could be used to accomplish this
task. Your CDs table has the columns: cd_number and title.
39. You want to compare the manufacturers id number to your product id
number. If they are the same, you want to mark the result column marked "null". If they
are not the same, return our product id number.
PRODUCTS
product_id manuf_id bin_number
19199
09199
998
91990
91990
889
40. From the DJ On Demand d_songs table, create a DECODE query and a CASE
query that replaces the 2 min songs with 'omit', the 5 min songs with "short" and the 10
minute songs with "long". All other durations should return the original column value.
Label the output column "Play Times"
Oracle Academy
7
Database Programming - Review
41. Display the first name, last name, auth_expense_amt for all DJ On Demand
employees. If they don't have an auth_expense_amt ,display the manager id, if they
don't have a manager, then display '99999' as "See Manager"
42. Use any database to create a join that illustrates each of the following. Be prepared
to show your answer to the class.
a. Cartesian Product or Cross Join
b. Equijoin
c. Nonequijoin
d. Outer Joins
e. Self Join
f. Natural Joins
g. Joins Using
h. Join On
i. Outer Joins Right, Left, Full
Oracle Academy
8