Database Concepts and SQL Functions
Test your knowledge of database fundamentals including views, constraints, joins, subqueries, and Oracle SQL functions like DECODE, NVL, NVL2, NULLIF, and date operations.
Questions
Which character is used to continue a statement in SQL*Plus?
- *
- /
- -
- @
Assuming today is Monday, 10 July 2000, what is returned by this statement: SELECT to_char(NEXT_DAY(sysdate, 'MONDAY'), 'DD-MON-RR') FROM dual;
- 17-JUL-00
- 11-JUL-00
- 09-JUL-00
- 03-JUL-00
SELECT NULLIF('testing','testing') FROM DUAL ;
- testing
- True
- null
- error
SELECT NULLIF(NULL,'testing') FROM DUAL ;
- testing
- True
- null
- error
SELECT NVL2(null,'second','third') FROM DUAL ;
- second
- third
- null
- error
SELECT NVL2('first','second','testing') FROM DUAL ;
- third
- null
- second
- error
SELECT NVL(null,'testing') FROM DUAL ;
- testing
- null
- False
- error
select decode('a','b','value-b','d','value-d','a','value-a','NA') result from dual;
- NA
- value-d
- value-b
- value-a
What is true about subqueries ?
- 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.
What is true about an equijoin?
- You can join a maximum of two tables through an equijoin.
- You can join a maximum of two columns through an equijoin.
- You can join n tables (all having single column primary keys) in a SQL statement by specifying a minimum of n-1 join conditions.
- To join two tables through an equijoin, the columns in the join condition must be primary key and foreign key columns.
- You specify an equijoin condition in the SELECT or FROM clauses of a SELECT statement.
What type of object privileges can be granted on a view?
- DELETE, INSERT,SELECT
- DELETE, INSERT, SELECT, UPDATE
- ALTER, DELETE, INSERT, SELECT
- NONE
Two reasons to create table alias :
- You have too many tables.
- You have too many columns in your tables.
- You want to work on your own tables.
- You want to use another schema's tables.
- Your tables have difficult names.
- Your tables are too long.
When the full outer join is used?
- You want all unmatched data from both tables.
- One of the tables has more data than the other.
- You want all matched data from both tables.
- You want all matched and unmatched data from only one table.
Which constraint can only be applied at the column level?
- Primary Key
- Check
- Not Null
- Unique
What is true about WHERE clause ?
- A WHERE clause can be used to restrict rows only.
- A WHERE clause CANNOT be used in a query if the query uses a HAVING clause.
- WHERE clause can be used to restrict both rows and groups.
- WHere clause filters the columns from the output
What is true about the Truncate statement?
- It is faster than the Delete operation.
- You can roll back the deletion of rows after the statement executes.
- You must be the owner of the table or have DELETE ANY TABLE system privileges
- It releases the storage space used by the table.
WHat is not true about the constaints ?
- A UNIQUE index gets created for columns with PRIMARY KEY and UNIQUE constraints.
- The UNIQUE constraint does not permit a null value for the column
- The NOT NULL constraint ensures that null values are not permitted for the column
- The PRIMARY KEY and FOREIGN KEY constraints create a UNIQUE index
Once a sequence is created
- It is automatically used in all INSERT and UPDATE
- It is linked to a specific table.
- It belongs to a specific schema.
- It is automatically available to all users.
PRODUCT ======= Product ID Product Description Manufacturer ID MANUFACTURER ============ Manufacturer ID Manufacturer Name Referring to the above table, what type of relationship exists between the Product table and the Manufacturer table?
- Product - Many,Manufacturer - Many
- Product - One or Many,Manufacturer - One or Many
- Product - Many,Manufacturer - One
- Product - One,Manufacturer - One
- Product - One,Manufacturer - Many
You are writing a database application to run on your DBMS. You do not want your users to be able to view the underlying table structures. At the same time you want to allow certain update operations. Referring to the above scenario, what structure will you deploy?
- Cursor table
- Table filter
- Dynamic procedure
- View
- Summary table