Database Management and SQL Functions
Quiz covering database administration concepts including SQL Server performance monitoring, indexing, stored procedures, data types, and PL/SQL functions for string manipulation, NULL handling, and exception handling.
Questions
What output will the follwing statement produce? Select NVL2(NULL,'NOT NULL', NULL) from dual?
- NULL
- NOT NULL
- Function NVL2 is not defined
- None of the above
Functions for error trapping are contained in which section of a PL/SQL block?
- Header
- Declarative
- Executable
- Exception
What is the result if two NULL values are compared to each other?
- TRUE
- FALSE
- Undefined
- NULL
PL/SQL raises an exception, in which TWO of the following cases?
- When a SELECT statement returns more than one row
- When a SELECT statement returns no rows
- When INTO statement is missing in the SELECT statement
- Both I and II
What output will the follwing statement produce? Select NVL2(NULL,NOT NULL, NULL) from dual?
- NULL
- NOT NULL
- Function NVL2 is not defined
- None of the above
Which SELECT statement will get the result 'elloworld' from the string 'HelloWorld'?
- SELECT INITCAP(TRIM ('HelloWorld', 1,1)) FROM dual;
- SELECT SUBSTR( 'HelloWorld',1) FROM dual;
- SELECT LOWER(SUBSTR('HelloWorld', 1, 1) FROM dual;
- SELECT LOWER(TRIM ('H' FROM 'HelloWorld')) FROM dual;
COALESCE (A,B)is equivalent to?
- CASE WHEN B IS NOT NULL THEN A ELSE B
- CASE WHEN A IS NOT NULL THEN A ELSE B
- CASE WHEN A IS NOT NULL THEN B ELSE A
- CASE WHEN A IS NOT NULL THEN A ELSE A
In which case would you use a FULL OUTER JOIN?
- Both tables have NULL values.
- You want all matched data from both tables.
- You want all unmatched data from both tables.
- You want all unmatched data from one table.
mod(-15, 4)would return ?
- 15
- -15
- -3
- 3
instr(Tech on the net, e, -3, 2) would retrun
- 10
- 8
- 6
- 2
power(-5, 3) would return ?
- -15
- -125
- 125
- 15
TRUNC(44.647, -1) would retrun ?
- 44.6
- 44
- 40
- 43
Your company has created a custom application that will require the use of several stored procedures. The lifetime of this application is relatively short and you wish to create the stored procedures such that they can all be dropped with a single DROP PROCEDURE statement command at the end of the application's lifetime. How can you group the procedures together such that they can all be dropped with a single DROP PROCEDURE statement?
- Create each procedure with a distinct name followed by a semi-colon and a group name.
- Create each procedure with a distinct name followed by a semi-colon and a group number.
- Create each procedure with the same name followed by a semi-colon and a group name.
- Create each procedure with the same name followed by a semi-colon and a distinct number.
You have a mission critical database named MCDB1 that you want to configure for automatic failover. You have decided to utilize database mirroring. Which database mirroring operating mode should you use?
- High safety mode
- Asynchronously
- High performance mode
- Synchronously
You have been assigned the task of designing a relational database for a client. The database will be used to store an exact copy of specific XML documents that the client needs to retrieve on a regular basis. The client wants to be able to use an application that they created to enter the documents into the database as well as retrieve them. You are in the process of designing a table for the database. What should you do?
- Convert the XML documents to relational data and then store them within the database
- Create a table that uses XML as the data type for the column that will store the XML documents.
- Nothing. You can not store XML documents within a SQL Server 2005 database
- Create a table that uses nvarchar(max) as the data type for the column that will store the XML documents
EasyYatra is a travel booking company that has a web site available for customers to view and book their vacations online. You have been hired to look after the back-end SQL Server that is used to store customer and booking information. You are creating a table called Booking to keep track of vacations booked by customers. This table will contain a computed column called Total that is derived from other columns in the table. You want to be able to create an index on this Total column to increase performance when any queries are executed using this column. To do this, you want to physically store the computed column in the table. How can this be done?
- Mark the computed column as PERSISTED.
- Define the computed column as NULL.
- Specify the collation for the column using COLLATE Physical.
- Do nothing. Computed columns are stored in the table by default.
You are gathering performance and optimization data for your SQL Server 2005 database. Your company has three custom applications that routinely make use of the database. Each application accesses the database using separate login credentials. You wish to gather information concerning the queries executed by each custom application. To gather this data you decide to create a trace using the SQL Server Profiler. You decide to use one of the predefined SQL Server Profiler templates to define what data should be gathered. Which predefined SQL Server Profiler template would best suit your requirements?
- TSQL_Duration
- TSQL_Grouped
- TSQL_Replay
- TSQL_SPs
Which task can you perform using only the TO_CHAR function?
- convert 10 to 'TEN'
- convert '10' to 10
- convert '10' to '10'
- convert 'TEN' to 10
In which scenario would an index be most useful?
- The indexed column is declared as NOT NULL.
- The indexed columns are used in the FROM clause.
- The indexed columns are part of an expression.
- The indexed column contains a wide range of values.