Oracle Database Fundamentals and SQL
Covers core SQL concepts including queries, functions, views, subqueries, DML operations, and SQL*Plus commands for Oracle databases
Questions
Which are DML statements? (Choose all that apply.)
- COMMIT
- MERGE
- UPDATE
- DELETE
- CREATE
- DROP
Which four are correct guidelines for naming database tables? (Choose four.)
- Must begin with either a number or a letter
- Must be 1-30 characters long
- Should not be an Oracle Server reserved word
- Must contain only A-Z, a-z, 0-9, _, *, and #
- Must contain only A-Z, a-z, 0-9, _, $, and #
- Must begin with a letter
Which SQL statement generates the alias Annual Salary for the calculated column SALARY*12?
- SELECT ename, salary*12 'Annual Salary' FROM employees;
- SELECT ename, salary*12 "Annual Salary" FROM employees;
- SELECT ename, salary*12 AS Annual Salary FROM employees;
- SELECT ename, salary*12 AS INITCAP("ANNUAL SALARY") FROM employees
Which operator can be used with a multiple-row subquery?
- =
- LIKE
- BETWEEN
- NOT IN
- Is
- <>
You need to display the last names of those employees who have the letter "A" as the second character in their names. Which SQL statement displays the required results?
- SELECT last_name FROM EMP WHERE last_name LIKE '_A%';
- SELECT last_name FROM EMP WHERE last name ='*A%'
- SELECT last_name FROM EMP WHERE last name ='_A%';
- SELECT last_name FROM EMP WHERE last name LIKE '*A%'
Which two are character manipulation functions? (Choose two.)
- TRIM
- REPLACE
- TRUNC
- TO_DATE
- MOD
- CASE
Which clause should you use to exclude group results?
- WHERE
- HAVING
- RESTRICT
- GROUP BY
- ORDER BY
Which is an /SQL*Plus command?
- INSERT
- UPDATE
- SELECT
- DESCRIBE
- DELETE
- RENAME
A subquery can be used to _________.
- create groups of data
- sort data in a specific order
- convert data to a different format
- Retrieve data based on an unknown condition
What does the TRUNCATE statement do?
- Removes the table
- Removes all rows from a table
- shortens the table to 10 rows
- Removes all columns from a table
- Removes foreign keys from a table
Which substitution variable would you use if you want to reuse the variable value without prompting the user each time?
- "&"
- ACCEPT
- PROMPT
- "&&"
Which two statements about views are true? (Choose two)
- A view can be created as read only
- A view can be created as a join on two or more tables.
- A view cannot have an ORDER BY clause in the SELECT statement
- A view cannot be created with a GROUP BY clause in the SELECT statement
- A view must have aliases defined for the column names in the SELECT statement
Management has asked you to calculate the value 12salarycommission_pct for all the employees in the EMP table. The EMP table contains these columns: LAST NAME VARCHAR2(35) NOT NULL SALARY NUMBER(9,2) NOT NULL COMMISSION_PCT NUMBER(4,2) Which statement ensures that a value is displayed in the calculated column for all employees?
- SELECT last_name, 12salarycommission_pct FROM emp;
- SELECT last_name, 12salary (commission_pct,0) FROM emp;
- SELECT last_name, 12salary(nvl(commission_pct,0)) FROM emp
- SELECT last_name, 12salary(decode(commission_pct,0)) FROM emp;
Examine the description of the STUDENTS table: STD_ID NUMBER(4) COURSE_ID VARCHAR2(10) START_DATE DATE END_DATE DATE Which two aggregate functions are valid on the START_DATE column? (Choose two.)
- SUM(start_date)
- AVG(start_date)
- COUNT(start_date)
- AVG(start_date, end_date)
- MIN(start_date)
- MAXIMUM(start_date)
Evaluate the SQL statement: SELECT ROUND (TRUNC (MOD (1600, 10),-1), 2) FROM dual; What will be displayed?
- 0
- 1
- 0.00
- An error statement
Examine the description of the MARKS table: STD_ID NUMBER(4) STUDENT_NAME VARCHAR2(30) SUBJ1 NUMBER(3) SUBJ2 NUMBER(3) SUBJ1 and SUBJ2 indicate the marks obtained by a student in two subjects. Examine this SELECT statement based on the MARKS table: SELECT subj1+subj2 total_marks, std_id FROM marks WHERE subj1 > AVG(subj1) AND subj2 > AVG(subj2) ORDER BY total_marks; What is the result of the SELECT statement?
- The statement executes successfully and returns the student ID and sum of all marks for each student who obtained more than the average mark in each subject.
- The statement returns an error at the SELECT clause.
- The statement returns an error at the WHERE clause.
- The statement returns an error at the ORDER BY clause.
Which three SELECT statements display 2000 in the format "$2,000.00"? (Choose three.)
- SELECT TO_CHAR(2000, '$#,###.##') FROM dual;
- SELECT TO_CHAR(2000, '$0,000.00') FROM dual;
- SELECT TO_CHAR(2000, '$9,999.00') FROM dual;
- SELECT TO_CHAR(2000, '$9,999.99') FROM dual;
- SELECT TO_CHAR(2000, '$2,000.00') FROM dual;
- SELECT TO_CHAR(2000, '$N,NNN.NN') FROM dual;
What is necessary for your query on an existing view to execute successfully?
- The underlying tables must have data.
- You need SELECT privileges on the view.
- The underlying tables must be in the same schema.
- You need SELECT privileges only on the underlying tables.
You define a multiple-row subquery in the WHERE clause of an SQL query with a comparison operator "=". What happens when the main query is executed?
- SELECT ENAME FROM EMP WHERE SYSDATE-HIRE_DATE > 5;
- SELECT ENAME FROM EMP WHERE HIRE_DATE-SYSDATE > 5;
- SELECT ENAME FROM EMP WHERE (SYSDATE-HIRE_DATE)/365 > 5;
- SELECT ENAME FROM EMP WHERE (SYSDATE-HIRE_DATE)* 365 > 5;
Evaluate these two SQL statements: SELECT last_name, salary , hire_date FROM EMPLOYEES ORDER BY salary DESC; SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC; What is true about them?
- The two statements produce identical results.
- The second statement returns a syntax error.
- There is no need to specify DESC because the results are sorted in descending order by default.
- The two statements can be made to produce identical results by adding a column alias for the salary column in the second SQL statement.