Oracle_test7

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Sudha_test
S
Sudha_test
Community Contributor
Quizzes Created: 12 | Total Attempts: 38,127
| Attempts: 681 | Questions: 20
Please wait...
Question 1 / 20
0 %
0/100
Score 0/100
1. The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(4) ENAME VARCHAR2 (25) JOB_ID VARCHAR2(10)
Which SQL statement will return the ENAME, length of the ENAME, and the numeric position of the letter "a" in the ENAME column, for those employees whose ENAME ends with a the letter "n"?

Explanation

The correct answer is the first option: SELECT ENAME, LENGTH(ENAME), INSTR(ENAME, 'a') FROM EMPLOYEES WHERE SUBSTR (ENAME, -1,1) = 'n'. This query selects the ENAME, length of ENAME, and the numeric position of the letter "a" in the ENAME column. It filters the results to only include employees whose ENAME ends with the letter "n" by using the SUBSTR function to extract the last character of ENAME and comparing it to 'n'.

Submit
Please wait...
About This Quiz
SQL Quizzes & Trivia

This test is used to test your skills in joins , functions

Personalize your quiz and earn a certificate with your name on it!
2. Which clause would you use in a SELECT statement to limit the display to those employees whose salary is greater then 5000?

Explanation

The WHERE clause is used in a SELECT statement to specify a condition that must be met for a row to be included in the result set. In this case, the condition is that the salary must be greater than 5000. Therefore, the correct answer is WHERE SALARY > 5000.

Submit
3. Evaluate the SQL statement: SELECT ROUND(45.953, -1), TRUNC(45.936, 2) FROM dual; Which values are displayed?

Explanation

The SQL statement SELECT ROUND(45.953, -1), TRUNC(45.936, 2) FROM dual; will display the values 50 and 45.93. The ROUND function rounds the number 45.953 to the nearest 10, resulting in 50. The TRUNC function truncates the number 45.936 to 2 decimal places, resulting in 45.93.

Submit
4. You want to retrieve all employees, whether or not they have matching departments in the departments table. Which query would you use?

Explanation

The correct answer is "SELECT last_name, department_name FROM employees e LEFT OUTER JOIN departments d ON (e. department _ id = d. department _id);". This query uses a LEFT OUTER JOIN to retrieve all employees, whether or not they have matching departments in the departments table. The "LEFT OUTER JOIN" keyword ensures that all records from the left table (employees) are included in the result, regardless of whether there is a match in the right table (departments).

Submit
5. Which two are character manipulation functions?

Explanation

TRIM and REPLACE are character manipulation functions. TRIM is used to remove leading or trailing spaces from a string, while REPLACE is used to replace a specified substring with another substring in a string. Both functions assist in manipulating and modifying character data.

Submit
6. Which clause should you use to exclude group results?

Explanation

The HAVING clause should be used to exclude group results. The HAVING clause is used in conjunction with the GROUP BY clause to filter the results of a query based on a condition that applies to groups of rows. It allows you to specify conditions that must be met by the aggregated values in order for the group to be included in the result set. This is different from the WHERE clause, which is used to filter individual rows before they are grouped. The HAVING clause is specifically designed to filter groups of rows after they have been grouped.

Submit
7. Which is a valid CREATE TABLE statement?

Explanation

The answer is "CREATE TABLE EMP9$# (empid number(2));". This is a valid CREATE TABLE statement because it follows the correct syntax for creating a table in a database. The table name "EMP9$#" is alphanumeric and does not contain any special characters that are not allowed. The column "empid" is defined with a data type of "number(2)", which is also valid.

Submit
8. Examine the structure of the EMPLOYEES, DEPARTMENTS, and TAX tables. EMPLOYEES (ID ,ename,sal,deptid) DEPARTMENTS(deptid,dname) TAX(minsal ,maxsal, taxpercent) For which situation would you use a nonequijoin query?

Explanation

A nonequijoin query would be used to find the tax percentage for each of the employees. This is because the TAX table contains information about the tax percentage based on the salary range. By joining the EMPLOYEES table with the TAX table using a nonequijoin, we can compare the salary of each employee with the minsal and maxsal columns in the TAX table to determine the applicable tax percentage for each employee.

Submit
9. Which of these set operators will not sort the rows? (Choose the best answer.)

Explanation

The UNION ALL operator combines the result sets of two or more SELECT statements into a single result set, including all rows from all SELECT statements. However, it does not sort the rows in any specific order. Therefore, the UNION ALL operator will not sort the rows.

Submit
10. Which SQL statement returns a numeric value?

Explanation

The SQL statement "SELECT sysdate-hire_date FROM EMP;" returns a numeric value because it calculates the difference between the current date (sysdate) and the hire date, which are both numeric values. This calculation will result in a numeric value representing the number of days between the two dates.

Submit
11. If a compound query contains both a MINUS and an INTERSECT operator, which will be applied first? (Choose the best answer.)

Explanation

The explanation for the given correct answer is that the precedence of the operators in a compound query is determined by the order in which they are specified. Therefore, if a compound query contains both a MINUS and an INTERSECT operator, the one that is specified first will be applied first.

Submit
12. Study this statement:
select ename from emp union all select ename from ex_emp;
In what order will the rows be returned? (Choose the best answer.)

Explanation

The statement "select ename from emp union all select ename from ex_emp" will return the rows from each table grouped together, but they will not be sorted.

Submit
13. Which two statements are true about WHERE and HAVING clauses?

Explanation

The correct answer is that a WHERE clause can be used to restrict rows only, and a HAVING clause can be used to restrict groups only. The WHERE clause is used to filter rows based on a specified condition, while the HAVING clause is used to filter groups based on a specified condition. Therefore, the WHERE clause restricts the result set by filtering individual rows, while the HAVING clause restricts the result set by filtering groups of rows.

Submit
14. What is the result of this expression? Select one answer.
TRUNC(ROUND(FLOOR(CEIL(1.2)-.1) + .3445, 3), 2)

Explanation

The expression starts by calculating the ceiling of 1.2, which is 2. Then, it subtracts 0.1 from the result, giving 1.9. The floor of 1.9 is 1. Next, it adds 0.3445 to 1, resulting in 1.3445. The round function is then applied to this value, rounding it to 3 decimal places, which gives 1.345. Finally, the trunc function is used to truncate the value to 2 decimal places, resulting in 1.34.

Submit
15. Which statement lists the ID, name, and salary of the employee, and the ID and name of the employee's manager, for all the employees who have a manager and earn more than 4000?

Explanation

The correct answer is the fourth option. This query selects the employee_id, emp_name, and salary from the employees table, and also selects the employee_id and emp_name from the same table, but with an alias of "Mgr_id" and "Manager" respectively. It then joins the employees table with itself using the condition e.mgr_id = m.employee_id, ensuring that the selected employee has a manager. Finally, it filters the results to only include employees with a salary greater than 4000.

Submit
16. Consider this compound query:
select empno, hired from emp

union all

select emp_id,hired,fired from ex_emp;
The columns EMP.EMPNO and EX_EMP.EMP_ID are integer; the column EMP.HIRED is timestamp; the columns EX_EMP.HIRED and EX_EMP.FIRED are date. Why will the statement fail? (Choose the best answer.)

Explanation

The statement will fail because the first query selects two columns (empno and hired) while the second query selects three columns (emp_id, hired, and fired). The number of columns selected in each query must match in a union operation.

Submit
17. In which case would you use a FULL OUTER JOIN?

Explanation

A FULL OUTER JOIN is used when you want to retrieve all matched data from both tables, as well as all unmatched data from both tables. This means that you want to include all rows from both tables, regardless of whether they have a match in the other table. This is useful when you need to combine data from two tables and want to include all available information, even if there are unmatched records.

Submit
18. Examine the structure of the EMPLOYEES, DEPARTMENTS, and LOCATIONS tables.
 EMPLOYEES(id,name,deptid) ,
DEPT(deptid,dname,locid) ,
Location(locid,name)
Which two SQL statements produce the name, department name, and the city of all the employees who earn more then 10000?

Explanation

The two SQL statements that produce the name, department name, and city of all the employees who earn more than 10000 are:

1. SELECT emp_name, department_name, city FROM employees e JOIN departments d USING (department_id) JOIN locations 1 USING (location_id) WHERE salary > 10000;
2. SELECT emp_name, department_name, city FROM employees e, departments d, locations 1 WHERE e.department_id = d.department_id AND d.location_id = 1.location_id AND salary > 10000.

These statements join the EMPLOYEES, DEPARTMENTS, and LOCATIONS tables using the appropriate keys and filter the results based on the salary condition.

Submit
19. Which three are true regarding the use of outer joins?

Explanation

The first statement is true because the IN operator cannot be used in a condition that involves an outer join. The second statement is false because the (+) notation is used to perform an outer join, not on both sides of the WHERE condition. The third statement is true because a condition involved in an outer join cannot be linked to another condition using the OR operator. The fourth statement is false because an outer join is used to see all the rows, including those that do not meet the join condition. The fifth statement is true because the (+) notation is used in the WHERE condition to perform an outer join on a column without matching rows.

Submit
20. What is true about joining tables through an equijoin?

Explanation

An equijoin is a type of join where the join condition is based on the equality of values in specified columns between two tables. The equijoin condition can be specified in either the SELECT or FROM clauses of a SELECT statement. This means that the equijoin condition can be included in the WHERE clause, JOIN clause, or ON clause of the query.

Additionally, it is possible to join more than two tables through an equijoin. In fact, you can join n tables (all having single column primary keys) in a SQL statement by specifying a minimum of n-1 join conditions. This allows for more complex queries involving multiple tables to be executed.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 21, 2010
    Quiz Created by
    Sudha_test
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
The EMPLOYEES table contains these columns: ...
Which clause would you use in a SELECT statement to limit the display...
Evaluate the SQL statement: SELECT ROUND(45.953, -1), TRUNC(45.936, 2)...
You want to retrieve all employees, whether or not they have matching...
Which two are character manipulation functions?
Which clause should you use to exclude group results?
Which is a valid CREATE TABLE statement?
Examine the structure of the EMPLOYEES, DEPARTMENTS, and TAX tables....
Which of these set operators will not sort the rows? (Choose the best...
Which SQL statement returns a numeric value?
If a compound query contains both a MINUS and an INTERSECT operator,...
Study this statement: ...
Which two statements are true about WHERE and HAVING clauses?
What is the result of this expression? Select one answer. ...
Which statement lists the ID, name, and salary of the employee, and...
Consider this compound query: ...
In which case would you use a FULL OUTER JOIN?
Examine the structure of the EMPLOYEES, DEPARTMENTS, and LOCATIONS...
Which three are true regarding the use of outer joins?
What is true about joining tables through an equijoin?
Alert!

Advertisement