Oracle SQL Fundamentals
Test your knowledge of Oracle SQL including views, joins, subqueries, functions, constraints, and data types.
Questions
Select invalid variable types
- VARCHAR2
- VARCHAR1
- CHAR
- CHAR2
- INTEGER
- NUMBER
SELECT ROUND (-123.39953,-2) FROM DUAL;
- -123.40
- -100
- -120
- -123.30
SELECT ROUND(-123.39953,-3) FROM DUAL;
- 0
- 100
- 123
- -123
SELECT CONCAT(SUBSTR('MINDWORKS',-5,6),SUBSTR('KNOWMAX',-3,4)) FROM DUAL;
- KNOWMIND
- WORKSM
- WORKSMAX
- MAXWORKS
SELECT DECODE('MINDWORKS','WORKS','MINDWORK','KNOWMAX') FROM DUAL;
- KNOWMAX
- MINDWORKS
- WORKS
- MINDWORK
How many columns are presented after executing this query: SELECT address1||','||address2||','||address2 "Adress" FROM employee;
- 1
- 2
- 3
- 0
- 4
Which Oracle access method is the fastest way for Oracle to retrieve a single row?
- Primary key access
- Access via unique index
- Table access by ROWID
- Full table scan
You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The table is currently empty. Which statement accomplishes this task?
- ALTER TABLE students ADD PRIMARY KEY student_id;
- ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student_id);
- ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id;
- ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);
- ALTER TABLE students MODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id);
Which three are DATETIME data types that can be used when specifying column definitions? (Choose three.)
- TIMESTAMP
- INTERVAL MONTH TO DAY
- INTERVAL DAY TO SECOND
- INTERVAL YEAR TO MONTH
- TIMESTAMP WITH DATABASE TIMEZONE
Evaluate the set of SQL statements: CREATE TABLE dept (deptno NUMBER(2), dname VARCNAR2(14), loc VARCNAR2(13)); ROLLBACK; DESCRIBE DEPT What is true about the set?
- The DESCRIBE DEPT statement displays the structure of the DEPT table.
- The ROLLBACK statement frees the storage space occupies by the DEPT table.
- The DESCRIBE DEPT statement returns an error ORA-04043: object DEPT does not exist.
- The DESCRIBE DEPT statement displays the structure of the DEPT table only if there is a COMMIT statement introduced before the ROLLBACK statement.
Which data dictionary table should you query to view the object privileges granted to the user on specific columns?
- USER_TAB_PRIVS_MADE
- USER_TAB_PRIVS
- USER_COL_PRIVS_MADE
- USER_COL_PRIVS
The EMP table contains these columns: LAST NAME VARCHAR2(25) SALARY NUMBER(6,2) DEPARTMENT_ID NUMBER(6) You need to display the employees who have not been assigned to any department. You write the SELECT statement: SELECT LAST_NAME, SALARY, DEPARTMENT_ID FROM EMP WHERE DEPARTMENT_ID = NULL; What is true about this SQL statement?
- The SQL statement displays the desired results.
- The column in the WHERE clause should be changed to display the desired results.
- The operator in the WHERE clause should be changed to display the desired results.
- The WHERE clause should be changed to use an outer join to display the desired results.
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
For which two constraints does the Oracle Server implicitly create a unique index? (Choose two.)
- NOT NULL
- PRIMARY KEY
- FOREIGN KEY
- CHECK
- UNIQUE KEY
Which two are true about aggregate functions? (Choose two.)
- You can use aggregate functions in any clause of a SELECT statement.
- You can use aggregate functions only in the column list of the SELECT clause and in the WHERE clause of a SELECT statement.
- You can mix single row columns with aggregate functions in the column list of a SELECT statement by grouping on the single row columns.
- You can pass column names, expressions, constants, or functions as parameters to an aggregate function.
- You can use aggregate functions on a table, only by grouping the whole table as one single group.
- You cannot group the rows of a table by more than one column while using aggregate functions.
Which two statements about subqueries are true? (Choose two.)
- A single row subquery can retrieve data from only one table.
- A SQL query statement cannot display data from table B that is referred to in its subquery, unless table B is included in the main query's FROM clause.
- A SQL query statement can display data from table B that is referred to in its subquery, without including table B in its own FROM clause.
- A single row subquery can retrieve data from more than one table.
- A single row subquery cannot be used in a condition where the LIKE operator is used for comparison.
- A multiple-row subquery cannot be used in a condition where the LIKE operator is used for comparison.
You added a PHONE_NUMBER column of NUMBER data type to an existing EMPLOYEES table. The EMPLOYEES table already contains records of 100 employees. Now, you want to enter the phone numbers of each of the 100 employees into the table. Some of the employees may not have a phone number available. Which data manipulation operation do you perform?
- MERGE
- INSERT
- UPDATE
- ADD
- ENTER
- You cannot enter the phone numbers for the existing employee records.
In which case would you use a FULL OUTER JOIN?
- Both tables have NULL values.
- You want all unmatched data from one table.
- You want all matched data from both tables.
- You want all unmatched data from both tables.
- One of the tables has more data than the other.
- You want all matched and unmatched data from only one table.
Which two statements accurately describe a role? (Choose two.)
- A role can be given to a maximum of 1000 users.
- A user can have access to a maximum of 10 roles.
- A role can have a maximum of 100 privileges contained in it.
- Privileges are given to a role by using the CREATE ROLE statement.
- A role is a named group of related privileges that can be granted to the user.
- A user can have access to several roles, and several users can be assigned the same role.
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.