How can we help?

You can also find more resources in our Help Center.

177 terms

TSTC ITSE 1345 - Oracle SQL Final Exam Review

TSTC Waco ITSE 1345 - Oracle SQL Final Exam Review Summer 2011
STUDY
PLAY
Explain how LINESIZE, PAGESIZE, and FEEDBACK affect the output of your script
LINESIZE - command determines the total number of characters SQL *Plus displays in on line before beginning a new line.
PAGESIZE - default is 14; when you use the default, you repeat the heading every 14 rows.
FEEDBACK - command returns the number of records returned by a query.
Explain how Substitution Variables are used when writing scripts.
When you want to run the same script repeatedly, but want to be able to change a variable you would use a substitution variable. During the execution of the script the user will be prompted to input the variable to use.
Explain how the SPOOL command is used and what program it can be used in.
The SPOOL command, together with a file name, spools any subsequently issued SQL Plus or SQL command to a file. Just as with other file names, you can add a path to store the file in a directory other than your SQL Plus default directory. SQL Developer does not allow for spooling.
Explain the steps needed to run a script in SQL Developer
Load the file into the SQL Statement Box, by opening the location the file is stored and inserting it into the statement Box. Next you can press the F5 key.
Explain what a static data dictionary view is and how it is used
The static data dictionary stores details about database objects, such as tables, indexes, and views. Whenever a new object is added or an object is changed, data about the object is recorded in the data dictionary.
Explain what is found in the All Objects report folder in SQL Developer
Lists all objects accessible for the chosen database connection. Also lists a helpful dependencies report for accessing change impact.
List the different types of data dictionary views.
USER_, ALL_, DBA_, and V$
Write a statement for SQL*Plus that shows the dictionary.
DESC dict;
SELECT LIST of a subquery in an INSERT statement
SET clause of an UPDATE statement
Is The following statement is correct:
SELECT *
FROM instructor
ORDER BY phone
TRUE
What does the following function return? SELECT LENGTH(NULL),
FROM dual
Null
_________ and __________ functions are opposites of each other and provide a value in a group of rows.
Both MIN and MAX
_________ rows are not allowed in the relational model.
Orphan
___________ subqueries allow you to reference columns from the outer query and execute the inner query repeatedly
Correlated
____________ are useful for analyzing and exploring the relationships within your data
Self-joins
_________________ relationships are always optional relationships.
Recursive
__________________ inserts the current date and time.
SYSDATE
A _____ is a query definition stored in the database that looks just like a table, but does not have any physical rows
x
A _________ subquery returns a single column with a single row
Scalar
A calculation with a null always yields another null.
TRUE
A constraint must have a name in order for it to be disabled.
FALSE
A DML command automatically issues a COMMIT.
FALSE
A function that operates on a single value can have only one input parameter.
FALSE
A join across three tables can be expressed with the ________ join syntax.
ANSI
A space or value of zero is the same as NULL in a schema diagram
FALSE
A transaction is a logical unit of work.
TRUE
All SQL statements contained within a script must end with a semicolon or forward slash, even if they are done in SQL Developer.
TRUE
An outer join includes the result rows returned by an __________ plus extra rows where no matches are found.
Equijoin
Another name for a data dictionary view is __________________ or _________________.
static or dynamic
Checks whether any value in the list makes the condition true.
Any
Checks whether any value in the list makes the condition true.
Any
Comparison operators can compare multiple _________________.
Columns
Converting a text literal to DATE format requires the use of the TO_CHAR function.
TRUE
Dynamic views begin with a ___________.
V$
Explain Flashback queries and how they are used. Give an example of a FLASHBACK_TRANSACTION query and explain what it does row by row.
Orable's flashback query feature allows you to look at values of a query at a specific time in the past, such as before specfic DML statements occured. This can be usefull in case a suer accidentally performs an unintended but committed DML change. It can also be useful if you want to compare previous data to current data.
Explain how Dynamic SQL is used and give an example of a Dynamic SQL statement.
Dynamic SQL is used to be continuously updated by the background processes in the Oracle instance but never by the user.
Explain how Oracle treats locks when a database is being updated and needs to be viewed by other users.
When you issue a INSERT, UPDATE, DELETE, or MERGE statement, Oracle automatically locks the modified rows. The lock prevents other sessions from making changes to these rows. The lock is released when the session initiating change commits or rollsback.
Explain how you can optimize your queries with subqueries and the main advantage of doing so.
Subqueries allow you to nest multiple queries into each other. This gives you the ability to use one statement to break down a problem into individual components. Without nesting queries, you would be required to have multiple queries which could be time consuming and difficult to accomplish. With the ability to nest queries you can breakdown results to get the results you were needing in one statement.
Explain in detail the impact of INDEXES and how they are used by Oracle.
To achieve good performance for data retrieval and data manipulation statements Oracle uses indexes. In the same way you would use an index in the back of a book to quickly find information, Oracle uses indexes to speed up data retrieval. If the appropriate index does not exist on a table, Oracle needs to examine every row (called a full table scan), which can be time consuming.
Explain the differences in how an ANSI Full Outer Join and a Full Outer Join using the UNION Operator work
x
Explain why constraints are used when building tables.
Constraints are used to enforce the business rules of a system. For instance, "The salary of an employee may not be a negative number" may be enforced with a check constraint on the salary column. Constraints also ensure integrity and data consistency among all applications, no matter which program and ease the burden of programming the business rules in individual applications because the database enforces the constraint.
Explicit data type conversion is preferable to Oracle's implicit conversion.
TRUE
How many characters can be stored in the CHAR column/field?
2000
How many characters can you have using the VARCHAR data type?
4000
If a graphical representation of a table's box has __________ it means that the relationship is identifying.
rounded edges
If you are running a version of Oracle that is prior to 9i, it is best to use the ANSI Outer join.
FLASE
In a view you can give a column a different name than it has in the parent table.
TRUE
In SQL Developer field names and table names are shown in the color _______.
Black
Information that is returned after you run your statement are found in the __________ tab in SQL Developer.
Results
Instead of using the Oracle Outer Join Operator or the ANSI syntax, you can achieve the same result with two SQL statements: ____________ and a ____________
Equijoin and correlated subquery
It is always good practice to include the old values in the WHERE clause of UPDATE to ensure that another session or user has not changed the name in the meantime.
TRUE
It is common practice to place a HAVING clause before the GROUP BY clause.
FALSE
It is considered good form to put all SQL commands in all caps.
TRUE
It is not possible to limit or disable constraints using Dynamic SQL scripting.
FALSE
Joins involving multiple columns must always follow the primary key/foreign key relationship path.
TRUE
List 4 aggregate functions
COUNT(registration_date), AVG (capacity), MIN (capacity), MAX (capacity)
List 6 Table-Related Menu Choices
RENAME, COPY, DROP, TRUNCATE, LOCK, & COMMENT
List the reasons that a subquery could not be unnested.
x
List the steps performed by a correlated subquery.
**** Select a row from the outer query, Determine the value of the correlated column, Execute the inner query for each record of the outer query., Feed the results of the inner query to the outer query and evaluate it. It if satisfies the criteria, return the row for output.Select the next record of the outer query and repeat steps 2 through 4 until all the records of the outer query are evaluated.
Match each of the SQL commands on the left with a verb from the list.
Control - Revoke
Define - TRUNCATE
Manipulate - MERGE
NUMBER functions can be nested
TRUE
Oracle prefers that you use the unique index syntax for future compatibility.
FALSE
Oracle uses the outer join operator to indicate that nulls are shown for non-matching rows.
TRUE
Primary key values should always be subject to frequent change.
FALSE
Queries that are found in parentheses are done first, just as in the order of operations when doing mathematical equations.
TRUE
Returns rows if the condition is true for all the values in the list
All
Self-joins are useful for performing comparisons and checking for inconsistencies in data.
TRUE
SQL Developer provides an extensive list of useful reports and offers the capability to create your own user-defined reports
TRUE
SQL Developer's ____________________ option allows you to selectively export certain rows and columns.
Export Data
SQL*Plus is used more than SQL Developer when you need to run scripts.
TRUE
Subqueries can return multiple rows.
TRUE
Substitution variables are limited to the WHERE clause of a statement.
FALSE
The ______ operator compares a list of values for equivalency
ANY
The _______ function adds values together for a group of rows.
SUM
The _______ operator determines common rows.
INTERSECT
The ________ operator cannot compare against a list of values.
LIKE
The __________ operator is inclusive of the two values specified.
BETWEEN
The ___________ operator tests whether a matching row cannot be found.
x
The ____________ clause on a CREATE TABLE statement can specify how much space to allocate.
STORAGE
The ____________ command makes changes permanent.
COMMIT
The ____________ icon allows you to execute multiple statements and emulates SQL *Plus as much as possible.
RUN SCRIPT
The ____________ keywords and the USING clause of the ANSI join syntax are mutually exclusive.
NATURAL JOIN
The _____________ clause determines how rows are grouped.
GROUP BY
The ________________ is a type of statement whereby you retrieve data that exists in one table, but not in another.
MINUS
The ALL operator returns true if any value in the list satisfies the condition.
FALSE
The ALTER SESSION statement can change the session's time zone.
TRUE
The bitmap index is the most common index structure in Oracle.
FALSE
The common column used in the join condition must be listed in the SELECT list.
FALSE
The COUNT function is useful for determining whether a table has data.
TRUE
The COUNT function uses the __________ wildcard.
Asterisk
The crow's foot depicts the M of a 1:M relationship.
TRUE
The data dictionary is used by Oracle externally to build diagrams.
FALSE
The Data tab in SQL Developer allows you to perform all the major DML commands, using the SQL *Plus interface.
FALSE
The data type definitions NUMBER(10) and NUMBER(10,0) are the same.
TRUE
The DECODE function lets you perform if-then-else functionality with the SQL language.
TRUE
The DUAL table can be used for testing functions.
TRUE
The eraser icon removes all statements in SQL *Plus
FALSE
The EXISTS operator can return True, False or Unknown
FALSE
The focus of the logical data model is _____________
business problems
The INSERT statement creates new data in a table only through single rows.
FALSE
The key that most database designers prefer and is chosen by the system is the _____________ key.
Surrogate
The lack of a unique index key is frequently the reason for slow performance of updates and deletions
FALSE
The MIN and MAX functions cannot take other data types as parameters.
FALSE
The MINUS operator shows likenesses between sets of rows.
FALSE
The NEXTVAL and CURRVAL pseudocolumns can be used in which of the following SQL constructs? Select all that apply.
VALUES clause of an INSERT statement
The Nonequijoin can use the ________________ operator to construct joins that are not based on equality of values.
BETWEEN
The number of rows in a table matches the number of columns
FALSE
The ORDER BY clause is allowed in subqueries.
FALSE
The purpose of the HAVING clause is to eliminate___________.
Groups
The query retrieves more than 5 to 15 percent of the rows
The indexed column is part of an expression. In this case, consider creating a function-based index instead
The ROUND function can take only the NUMBER data type as a parameter
FALSE
The ROWID pseudocolumn is not an actual column, but it acts like one.
TRUE
The RTRIM function is useful for eliminating extra spaces in a string.
TRUE
The same function can be used twice in a SELECT statement.
TRUE
The SELECT command always places locks on retrieved rows.
FALSE
The self join is different from other joins because it does not utilize a primary key or a foreign key.
FALSE
The surrogate key generated by a sequence is often used by the DBA and is changed often.
FALSE
The term ____________ ___________ is used to express a join that satisfies the join condition.
INNER JOIN
The time zone displacement value indicates the time difference from _______.
UTC
The TIMESTAMP WITH LOCAL TIME ZONE data type allows fractional seconds.
TRUE
The TRUNC function on a date without a format model truncates the timestamp to 12:00:00 A.M.
TRUE
The using clause of the ANSI join syntax always assumes an equijoin and identical column names.
TRUE
To equijoin a table with another table involves matching the common column value.
TRUE
To join four tables, you must have at least three join conditions.
TRUE
To place a line comment in your SQL statements, you first place a // at the beginning of the line.
FALSE
To restart a sequence at a lower number, you can drop and re-create the sequence.
TRUE
To revert back to a state that happened before you ran your change statement, you issue a ____________ command.
ROLLBACK
UNION ALL does not sort, therefore it is less time consuming to use than the UNION operator.
TRUE
Users can only see changes made to a database once they have been committed.
TRUE
Usually a script only needs to be run and tested one time to make sure that it is functional.
FALSE
What are the main components of a ROWID?
The main components of a ROWID are the data object number, the number of the data block, the numbers of rows within the data block, and the data file number.
What do views do that makes them so useful for security?
hide data
What does SQL stand for?
Structured Query Language
What is Oracle's most popular index storage structure?
B-Tree Index
What is the command you would type into SQL*Plus if you needed to know the definition for each column of a table?
DICT_COLUMNS
What is the data type you can use if you need an unlimited number of textual characters?
CLOB
What is the first column of a composite index called?
leading-edge
What is the keyboard shortcut for the ROLLBACK command?
F12
What is the main difference between the NOT EXISTS and the NOT IN operators?
The way NULL values are treated
What is the maximum value for a column defined as NUMBER(4,2)?
99.99
What is the most common DATE format found in SQL?
DD-MON-YY
What is the name of the key automatically generated from a sequence?
surrogate key
What is the name of the view where you can find the collection of static and data dictionary tables and views, along with their descriptions?
DICTIONARY
What is the Oracle data dictionary called that contains a set of tables and views containing the data about the database?
ALL_OBJECTS
What is the syntax used to indicate that you are using the Oracle Outer Join operator?
+
What is the tab in SQL Developer where data dictionary view information can be found?
Details
When column names on the tables are different, you use the ______ condition.
ON
When disabling a unique or primary key, you can keep the index if you specify the __________________ clause in the ALTER TABLE statement.
KEEP INDEX
When is it not a good idea to use an index?
When the table is small (unless your business rules require you too)
When returning multiple rows, a subquery must contain the _____, _____, _____, or ______ operator, otherwise Oracle will return an error
IN ANY ALL SOME
When using the data NUMBER(10,4) there will be _______ digits following the decimal point.
4
When using the following data: NUMBER(10,4) - the # 10 is called the __________.
Precision
When using the following data: NUMBER(10,4) - the # 4 is called the __________.
Scale
When using the following data: NUMBER(10,4) - the lowest number you can possibly have is __________.
-999999.9999
When writing an ANSI outer join, the keywords _________ OUTER and _________ OUTER are added to the __________ keyword to indicate the rows from which table to use.
RIGHT LEFT JOIN
When writing the syntax for finding information on three or more tables, the parenthesis around the ON clause is optional.
TRUE
When you create a report in SQL Developer all the column names must match identically the names of the columns found in the tables you are referencing.
FALSE
When you have issued a DELETE command, you can still retrieve those rows and restore the information.
TRUE
When you INSERT new information into a table, it is followed with a _______ keyword that contains the information that is going to be added to the table.
VALUES
When you run a script in SQL*Plus you must give the location of the file.
TRUE
When you want to run a script in either SQL*Plus or SQL Developer, you can use a ______ or the _________ command.
@ or START
Which format mask displays December 31st, 1999?
Month ddth, yyyy
Which one of the following string functions tells you how many characters are in a string?
LENGTH
Which operator is most commonly used?
UNION
Write a solution that adds 20 minutes to a given date.
SELECT SYSDATE+1/96
FROM dual
Write a statement that drops the index need_to_pass_i
DROP INDEX need_to_pass_i
Write an SQL statement for SQL *Plus in which you want any unique menu items to be displayed from the restaurant table
SELECT DISTINCT menu
FROM restaurant
Write the syntax to rename index just_two_more_weeks_i to finally_i
RENAME just_two_more_weeks TO finally_i
You can combine DISTINCT and a GROUP BY clause in the same SELECT statement.
TRUE
You can pass parameters from the operating system when running a script file in SQl*Plus
TRUE
You can simplify the writing of SQL statements by writing SQL _________ that generate and execute other SQL statements.
Script
You can use the ADD_MONTHS functi0n to subtract months from a given date.
TRUE
You cannot create a table from another table if it has no rows.
False
You must explicitly indicate whether an ORDER BY clause is ascending.
FALSE
You must ORDER BY a column listed on your SELECT statement.
False
You use the _________ keyword to add columns or constraints to a table.
ADD
You use the __________ keyword to change characteristics of a column.
MODIFY