• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/88

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

88 Cards in this Set

  • Front
  • Back

What is projection?

Limiting the columns retrieved by a SELECT statement.

What is selection?

Restricting the rows returned

The ______ clause specifies one or more conditions that the Oracle server evaluates to restrict the rows returned by the statement.

WHERE

The ______ clause provides data sorting capabilities.

ORDER BY

____ ____ introduces a way to reuse the same statement to execute different queries by substituting query elements at runtime.

Ampersand substitution

Conditions restrict rows using what?

comparison operators in conjunction with columns and literal values.

_____ ______ provide a mechanism to specify multiple conditions to restrict the rows returned.

Boolean operators

What extends the SELECT statement by providing the language to restrict rows returned based on one or more conditions?

The WHERE clause



Querying a table with just the SELECT and FROM clauses results in what?

Every row of data stored in the table being returned.

What happens when you use the DISTINCT keyword?

Duplicate values are excluded, and the resultant rows are restricted to some degree.

The WHERE clause most always come after what?

The FROM clause

A condition is specified by what?

By comparing two terms using a conditional operator.

The _______ operator is most commonly used to restrict result sets.

equality

T/F Conditions determining which rows are selected based on character data, are specified by enclosing character literals in the conditional clause, within single quotes.

True.

What would happen if you tried specifying the character literal without the quotes?

An oracle error would be raised.

Why are the following WHERE clauses not equivalent:




where job_id=SA_REP


where job_id='Sa_Rep'


where job_id='sa_rep'

1. Clause 1 generates an "ORA-00904: invalid identifer" error since the literal SA_REP is not wrapped in single quotes.


2. Clause 2 and 3 are syntactically correct but not equivalent.

T/F Date literals must be enclosed in single quotation marks just like character data; otherwise an error is raised.

True.

When used in conditional WHERE clauses, DATE columns are compared to ______.

other DATE columns or to date literals

If a literal occurs in an expression involving a DATE column, it is automatically converted into what?

a date value using the default format mask (DD-MON-RR)

______ _______ compare two terms using comparison operators.

Conditional clauses.

The ________ ________ like "less than" or "greater than or equal to" may be used to return rows conforming to inequality conditions.

inequality operators

The _____ _______ facilitates range-based comparison to test whether a column value lies between two values.

BETWEEN operator

The ____ _____ tests set membership, so a row is returned if the column value tested in the condition is a member of a set of literals.

IN operator

The pattern matching comparison operator _____ is extremely powerful, allowing components of character column data to be matched to literals conforming to a specific pattern.

LIKE

The ____ _____ _____ returns rows where the column value contains a null value.

IS NULL operator

The _____ operator tests whether a column or expression value falls within a range of two boundary values.

BETWEEN

What does the IN operator test?

Whether an item is a member of a set of literal values. The set is specified by a comma separating the literals and enclosing them in round brackets. If the literals are character or date values, then these must be delimited using single quotes.

The IN operator is equivalent to a series of ______ ______.

OR conditions.

What is the syntax for the IN Operator?

Select (column name) from (table name)


where (column name) in (____, _____, .....);

The LIKE operator is accompanied by what two wildcard characters?

1. the percentage symbol (%)


2. the underscore character (_).

What does the percentage symbol specify?

Zero or more wildcard characters

What does the underscore character specify?

old wildcard character.

T/F A wildcard may represent any character

True.

What would be the syntax if you wanted to retrieve the first name of all employees ?

select first_name from employees


where first_name like 'A%';

What would the following syntax return?




select first_name from employees


where first name like '%';

Every row containing a first_name value that is not null will be returned.

T/F Wildcard symbols are mandatory when using the LIKE operator.

False. LIKE behaves as an equality operator testing for exact character matches.

Are the following clauses equivalent?




where last_name like 'King';


where last_name = 'King';



Yes, they are equivalent.

What would be the syntax if you wanted to search for all employees whose last names are four letters long, begin with a "K," have an unknown second letter, and end with an ng?

where last_name like 'K_ng';

T/F It is not practically possible to perform character pattern matching without the user of the LIKE operator and the wildcard symbols.

True

T/F A naturally occurring underscore character may be escaped (or treated as a regular nonspecial symbol) using the ESCAPE identifier in conjunction with an ESCAPE character.

True.

The ESCAPE identifier instructs the Oracle server to do what?

Treat any character found after the backslash character as a regular nonspecial symbol with no wildcard meaning.

What is the syntax for a query that fetches the last_name column from the employees table for those rows which have NULL values stored in the commission_pct column?

select last_name from employees


where commission_pct is null;

________ or _________ operators enable multiple conditions to be specified in the WHERE clause of the SELECT statement.

Boolean or logical

What does the AND operator do?

It merges conditions into one larger condition to which a row must conform to be included in the results set.

Boolean operators are defined using _____ _____.

truth tables.

T/F If two conditions specified in a WHERE clause are joined with an AND operator, then a row is tested consecutively for conformance to both conditions before being retrieved.

True

T/F If two conditions in a WHERE clause conform to neither or only one of the conditions, the row is excluded since the result is FALSE>

True.

A row will only be returned if every condition joined with an AND operator evaluates to _____.

TRUE.

In a scenario with more than two conditions joined with the AND operator, what will be returned?

Only data conforming to every condition will be returned.

What syntax returns employee records with first_name values beginning with the letter "J" and COMMISSION_PCT greater than 10 percent?

select first_name, last_name, commission_pct, hire_date


from employees


where first_name like 'J%'


and commission_pct > 0.1;

What does the OR operator do?

It separates multiple conditions, at least one of which must be satisfied by the row selected to warrant inclusion in the results set.

T/F If two conditions specified in a WHERE clause are joined with an OR operator then a row is tested consecutively for conformance to either or both conditions before being retrieved.

True.

T/F Conforming to just one of the OR conditions is not sufficient for the record to be returned.

False. It is sufficient.

T/F A row will only be returned if at least one of the conditions associated with an OR operator evaluates to TRUE.

True


What is the syntax for retrieving employee records having first_name values beginning with the letter B or those with a commission_pct greater than 35%?

select first_name, last_name, commission_pct, hire_date


from employees


where first_name like 'B%'


or commission_pct > 0.35;

T/F The more OR conditions you specify, the more restrictive your query becomes.

False. The more OR conditions, the less restrictive it becomes.

You have a complex query with multiple conditions. Is there a restriction on the number of conditions you can specify in the WHERE clause? Is there a limit to the number of comparison operators you can use in a single query?

No. You may specify any number of conditions in the WHERE clause separated by the Boolean operators. There is no limit when using the comparison operators, and they may be specified multiple times if necessary in a single query.

You have been tasked to locate rows in the EMPLOYEES table where the SALARY values contain the numbers 8 and 0 adjacent to each other. The SALARY column has a NUMBER data type. Is it possible to use the LIKE comparison operator with numeric data?

Yes. Oracle automatically casts the data into the required data type, if possible. In this case, the numeric SALARY values are momentarily "changed" into character data allowing the user of the LIKE operator to locate matching patterns. The following query locates the required rows:




select * from employees


where salary like '%80%',"

By restricting the rows returned from the JOBS table to those which contain the value SA_REP in the JOB_ID column, is a projection, selection, or join performed?

A selection is performed since rows are restricted.

What is the NOT operator?

It negates conditional operators in a condition, whether it's an equality, inequality, range based, pattern matching, set membership, or null testing operator. A selected row must conform to the logical opposite of the condition in order to be included in the results set.

What is the syntax for a query that retrieves employee records with first_name values that do NOT begin with the letter "B" or those that do NOT comply with a commission_pct greater than 35%?

select first_name, last_name, commission_pct, hire_date


from employees


where first_name not like 'B%'


or not (commission_pct > 0.35);

What does the ORDER BY clause do?

This clause is responsible for transforming the output of a query into more practical, user-friendly sorted data.

T/F The ORDER BY clause is always the last clause in a SELECT statement.

True.

What is the default sort order when the ORDER BY clause is specified?

ascending sort order.

What is the ascending sort order for numbers, dates and characters?

An ascending sort order for numbers is lowest to highest, while it is earliest to latest for date and alphabetically for characters.

T/F If null values occur in the sort column, the default sort order is assumed to be NULLS LAST for ascending sorts and NULLS FIRST for descending sorts.

True

T/F If no ORDER BY clause is specified, the same query executed at different times will still return the same set of results in the same row order.

False. If no order by clause is specified, the same query executed at different times may return the same set of results in different row order, so no assumptions should be made regarding the default row order.

Results of a query may be sorted by more than one column using what?

composite sorting

T/F Any text, subclause or clause element, or even the entire SQL query is a candidate for substitution.

True

What is the most basic and popular form of substitution of elements in a SQL statement?

single ampersand substitution

The _____ _____ is the symbol chosen to designate a substitution variable in a statement and precedes the variable name with no spaces between them.

ampersand character (&)

When a statement that includes the ampersand character is executed, what does the Oracle server do?

It notices the substitution variable and attempts to resolve this variable's value in one of two ways:


1. First, it checks whether variable is defined in user session.


2. If the variable is not defined, the user process prompts for a value that will be substituted in place of the variable.




Once the value is submitted, the statement is complete and is executed by the Oracle server.

The ampersand substitution variable is resolved at execution time and is sometimes known as what?

runtime binding or runtime substitution

What will the Oracle server do when a substitution variable is reference multiple time in the same query?

The Oracle server will prompt you to enter a value for every occurrence of the single ampersand substitution variable.

____ ____ _____ is used to avoid repetitive input when the same variable occurs multiple times in a statement.

double ampersand substitution

When a double amperand substitution occurs, the variable is stored as a ______ ______.

Session variable

The _____ ______ is specific to SQL*Plus and controls whether or not substituted elements are echoed on the user's screen prior to executing a SQL statement that uses substitution variables.

Verify command

T/F Session level variables are implicitly created when they are initially referenced in SQL statements using double ampersand substitution. They persist or remain available for the duration of the session or until they are explicitly undefined.

True.

T/F A session ends when the user exits their client tool like SQL*Plus or when the user process is terminated abnormally.

True

What is the syntax for the undefine command?

UNDEFINE variable;

The DEFINE command serves what two purposes?

1. It can be used to retrieve a list of all the variables currently defined in your SQL session.


2. It can also be used to explicitly define a value for a variable referenced as a substitution variable by one or more statements during the lifetime of that session.



What is the syntax for the DEFINE command?

DEFINE;


DEFINE variabl=value;

The capacity of the SQL client tool to support session-persistent variables may be switched off and on as required using what command?

The SET command

T/F By specifying SET DEFINE OFF, the client tool does not save session variables or attach special meaning to the ampersand symbol.

True. This allows the ampersand symbol to be used as an ordinary literal character if necessary.

The _______ _____ _______ command determines whether or not ampersand substitution is available in your session.

SET DEFINE ON|OFF

Generic, reusable statements may be constructed using ____ ____ variables which prompt for runtime values during execution.

ampersand substitution

One or more conditions constitute a _____ _____.

WHERE clause.

The _____ environmental setting controls whether SQL*Plus displays the old and new versions of statement lines which contain substitution variables.

VERIFY