Database Oracle Pre-Final Exam and Quizes

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

Suppose that the user wanted to add a new column name as CUST_NAME data type char

size 6. What is the correct type of statement to use?

: ALTER

Database Management System is a collection of interrelated data and a set of programs to


access those data.

: True

Table is known as the collection of data that contains information relevant to an enterprise.

: False

Which of the following is not part of handling data?

: Semi-Computerized

Which of the following is not part of disadvantage of database?

: Data integrity

Which of the following is not part of advantage of database?

: Database instance

Which of the following is not part of basic SELECT statement

: Logical condition

Database Architecture is the overall design of the database

: False
Which of the following is not part of other Comparison Operator?

: <>

Which of the following is not part of common Comparison operator?

: LIKE

Which of the following is not part of DML statement?

: CREATE table

Which of the following is not part of characteristics of database?

: Data Processing

Database is the term generally used to describe what was done by large mainframe
computers from the late 1940's until the early 1980's.

: False

Security is one of the characteristic of database that includes also the protection of the
database from unauthorized access confidentiality and unauthorized changes.

: False

Which of the following is not part of DDL statement?

:  DELETE

Which of the following is not the correct example of entity?

: Phone_no
Extracts a string of determined length.

: SUBSTR

This is use to find the numeric position of a named character starting at character position n.

: INSTR

This is use to return one result per row.

: Single row

Trims leading or trailing characters (or both) from a character string.

: Trim

It is a table that is owned by the user SYS and can be accessed by all users.

: Dual

It is use to accept numeric input and return numeric values.

: Number function

This is use to return one result per group of row.

: Multiple row

This is use to accept character input and can return both character and number values.

: Character function

This is used to converts the first letter of each word to uppercase and the remaining letters
to lowercase.

: INITCAT
What is the return value if the user try to do the following:
SELECT TRUNC (65.73,-2) FROM DUAL;

:0

*** **

A type of function that accept numeric input and return numeric values

: Number Function

A type of function returns one result per row.

: SINGLE-ROW FUNCTIONS

This query returns rows in the first query that are not present in the second query.

: MINUS

A type of function returns one result per group of row

: MULTIPLE-ROW FUNCTIONS

Based on the given SELECT statement below what would be the possible output?
SELECT (LASTNAME||FIRSTNAME), JOB_ID
FROM EMPLOYEES
WHERE SUBSTR (JOB_ID,4)=’REP’;
: ABELELLEN                  SA_REP
TALORJONATHAN       SA_REP
GRANTKIMBERLY       SA_REP
FAYPAT                         MK_REP
What query should be used in order todisplay a report that trim the letter ‘A’ from lastname
of all employees whose department_id between 60 and 90.

: SELECT TRIM('A' FROM LASTNAME)

FROM EMPLOYEES
WHERE DEPARTMENT_ID BETWEEN 60 AND 90;

Based on the given SELECT statement below what would be the possible output?
SELECT MOD(SALARY,10) AS “EXCESS SALARY”
FROM EMPLOYEES
WHERE SALARY < 5000;
:0
0
0
0
0
0

Based on the given SELECT statement below what would be the possible output?
SELECT TRUNC(563.396,-2) FROM DUAL;
: 500

What query should be used in order toget theSUBSTR  function that returns the job_id =
‘REP’.

: SELECT JOB_ID FROM EMPLOYEES

WHERE SUBSTR(JOB_ID,4)='REP';

SELECT COUNT(*) FROM STOCKS;

:9
A type of function that accepts character input and can return both character and number
values.

: CHARACTER FUNCTION

SELECT COUNT(DISTINCT QTY) FROM STOCKS;

:4

SELECT MIN(ID) FROM STOCKS;

:1

SELECT AVG(NVL(QTY,0)) FROM STOCKS;

: 8.22

SELECT COUNT(PRICE) FROM STOCKS;

:3

SELECT MIN(PRICE) FROM STOCKS;

:7

This query returns the rows from both queries after eliminating duplications.

: UNION

What query should be used in order to display the firstname concatenated to salary with
additional column salary that provides a computation of salary * 2. Rename the column as
Increase of all employees whose lastname ends with N.

: SELECT (FIRSTNAME || 'SALARY OF' || SALARY || 'IF MULITPLY BY TWO THEN HE/SHE WLL
GOT A NEW SALARY OF' || SALARY * 2)AS INCREASE FROM EMPLOYEES WHERE LASTNAME
LIKE '%N';
This query returns rows from both queries including all duplications

: UNION ALL

Based on the given SELECT statement below what would be the possible output?
SELECT INITCAP(LASTNAME||’,’||FIRSTNAME) AS NAME
FROM EMPLOYEES
WHERE JOB_ID LIKE ’%PR%’;
: King,Steven
Hunold,Alexander
Ernst,Bruce
Lorentz,Diana

What query should be used in order to display the employees lastname concatenated to
salary. Format the salary column to 6 character long left padded with ‘*’ as special character
for all employees whose manager_id is null or salary between 4000 and 6000 Rename the
column as employees and their Salaries

: SELECT (FIRSTNAME||RPAD(SALARY,6,'*')) AS "EMPLOYEES AND THEIR SALARIES"

FROM EMPLOYEES
WHERE MANAGER_ID IS NULL
OR SALARY BETWEEN 4000 AND 6000;
Based on the given SELECT statement below what would be the possible output?
SELECT LASTNAME,SALARY, RPAD(SALARY,4,’@’)
FROM EMPLOYEES
WHERE SALARY BETWEEN 4000 AND 9000
LASTNAME LIKE ‘%S’;
: MOURGOS                      5800                5800

Based on the given SELECT statement below what would be the possible output?
SELECT TRUNC(563.396,2)FROM DUAL;
: 563.39

What query should be used in order todisplay the Firstname concatenated to employees
original salary plus concatenate again a new column salary that multiplies the original salary
into three. Rename the column as Dream Salaries.Note sort the salary in descending order.

: SELECT (FIRSTNAME||' EARNS '|| SALARY || 'MONTHLY BUT WANTS' || SALARY * 3)

AS "DREAM SALARIES"
FROM EMPLOYEES
ORDER BY SALARY DESC;

SELECT MAX(NAME) FROM STOCKS;

: ZONROX

Based on the given SELECT statement below what would be the possible output?
SELECT TRUNC(563.396,1)FROM DUAL;
: 563.3
Based on the given SELECT statement below what would be the possible output?
SELECT TRIM(‘K’ FROM LASTNAME)AS TRIM, LASTNAME, DEPARTMENT_ID, MANAGER_ID
FROM EMPLOYEES
WHERE DEPARTMENT_ID = 50
AND MANAGER_ID = 100;
: MOURGOS                      MOURGOS    50        100

What query should be used in order to display the lastname and salary of all employees
whose department_id = 60 or job_id like ‘_T%’. Format the salary to be 15 character long,
left padded with ‘$’ as special character. Label the column Salary.

: SELECT LASTNAME, LPAD(SALARY,15,'$') AS SALARY

FROM EMPLOYEES
WHERE DEPARTMENT_ID = 60 OR JOB_ID LIKE '_T';

A type of function that helps how to group rows in a table into smaller sets and how to
specify search criteria for groups of rows.

: GROUP FUNCTION

What query should be used in order todisplay the firstname and length of firstname rename
the column length of firstname as Number of Character of all employees whose salary is
between 4400 and 8300

: SELECT FIRSTNAME, LENGTH(FIRSTNAME) AS "NUMBER OF CHARACTER"

FROM EMPLOYEES
WHERE SALARY BETWEEN 4400 AND 8300;
****
Based on the given SELECT statement below what would be the possible output?
SELECT LOWER(LASTNAME||’with a salary of’||SALARY) as Record, LENGTH(LASTNAME) as
Lname
FROM EMPLOYEES
WHERE MANAGER_ID IS NULL
OR SALARY IS NULL;
: kingwith a salary of 24000                       4
hunoldwith a salary of 2400                     6

SELECT SUM(QTY) FROM STOCKS WHERE WAREHOUSE IN (1,5) GROUP BY WAREHOUSE


HAVING MAX(WAREHOUSE) >=5;

:1

SELECT AVG(WAREHOUSE) FROM STOCKS;

:5

Based on the given SELECT statement below what would be the possible output?
SELECT FIRSTNAME, SALARY, LPAD(SALARY * 0.10 + SALARY – 100, 8, ‘$’) AS BONUS
FROM EMPLOYEES
WHERE DEPARTMENT_ID NOT IN (10, 110, 50
AND SALARY=17000;
: NENA       17000              $$$18600
LEX          17000              $$$18600
What query should be used in order todisplay the firstname in capitalized format rename
the column as pangalan whose job_id is equal to ‘SA_REP’.

: SELECT UPPER(FIRSTNAME) AS PANGALAN

FROM EMPLOYEES
WHERE JOB_ID = 'SA_REP';

This query returns rows that are common to both queries.

: INTERSECT

What query should be used in order to display the salary leftpadded with 15 character long
and ‘$’ as special character and another column salary right padded with 10 character long
with ‘@’ as special character used of all employees in 201, 176 and 144.

: SELECT LPAD(SALARY,15,'$'), RPAD(SALARY,10,'@')

FROM EMPLOYEES
WHERE EMPLOYEE_ID IN (201,176,144);

SELECT COUNT (AVG(PRICE)) FROM STOCKS GROUP BY WAREHOUSE;

:3

It combines the results of two or more component queries into one result.

: Set Operators
What query should be used in order to display the employees lastname concatenated with
firstname and with a ‘, (comma)’ in between. A rename on the concatenated column as
Complete Name. Note all values in Complete Name column should be in lowercase plus
display the length of employees lastname for all employees whose lastname starts with
letter M sort the lastname in its default order.

: SELECT LOWER(LASTNAME||','||FIRSTNAME) AS "COMPLETE NAME",

LENGTH(LASTNAME)
FROM EMPLOYEES
WHERE LASTNAME LIKE 'M%';
-

You might also like