Chapter 02 Introducing SQL Flashcards
What is DML and what is it used for?
Database Manipulation Language is used to access, insert, modify, or delete data in the existing structures of the database.
DML Statements: SELECT, INSERT, UPDATE, DELETE, MERGE, EXPLAIN PLAN, LOCK TABLE,
What is DDL and what is it used for?
Data Definition Language is used to define, alter, or drop database objects and their privileges.
DDL Statements: CREATE, ALTER, DROP, RENAME, TRUNCATE, GRANT, REVOKE, AUDIT, NOAUDIT, COMMENT
How do you write the concatenation operator?
||
‘Oracle12c’ || ‘Database’ results in ‘Oracle12cDatabase’.
What is a query?
A query is a request for information from the database tables.
Does query modify data? If not, what does it do?
Queries do not modify data; they read data from database tables and views.
A table is used to [Blank] and is [Blank] in rows and columns.
A table is used to store data and is stored in rows and columns.
What does the SELECT statement do?
It allows you to retrieve information already stored in the database.
Column Alias Name Keyword
AS
Keyword to ensure unique rows
DISTINCT
What is the DUAL table and what is it used for?
The DUAL table is a special table available to all users in the database. The DUAL table is mostly used to select system variables or to evaluate an expression.
What is the LIKE keyword?
Using the LIKE operator, you can perform pattern matching.
The pattern-search character % is used to match any character and any number of characters.
The pattern-search character _ is used to match any single character.
What is the ORDER BY keyword?
ORDER BY clause to sort the resulting rows in a specific
order based on the data in the columns.
ASC
DESC
You issue the following query: SELECT salary "Employee Salary" FROM employees; How will the column heading appear in the result? A. EMPLOYEE SALARY B. EMPLOYEE_SALARY C. Employee Salary D. employee_salary
C. Column alias names enclosed in quotation marks will appear as typed. Spaces and mixed case appear in the column alias name only when the alias is enclosed in double quotation marks.
SELECT empno enumber, ename FROM emp ORDER BY 1;
2. SELECT empno, ename FROM emp ORDER BY empno ASC;
Which of the following is true?
A. Statements 1 and 2 will produce the same result in data.
B. Statement 1 will execute; statement 2 will return an error.
C. Statement 2 will execute; statement 1 will return an error.
D. Statements 1 and 2 will execute but produce different results.
A. Statements 1 and 2 will produce the same result. You can use the column name,
column alias, or column position in the ORDER BY clause. The default sort order is
ascending. For a descending sort, you must explicitly specify that order with the DESC
keyword.
You issue the following SELECT statement on the EMP table shown in question 2.
SELECT (200+((salary*0.1)/2)) FROM emp;
What will happen to the result if all the parentheses are removed?
A. No difference, because the answer will always be NULL.
B. No difference, because the result will be the same.
C. The result will be higher.
D. The result will be lower.
B. In the arithmetic evaluation, multiplication and division have precedence over addition
and subtraction. Even if you do not include the parentheses, salary*0.1 will be
evaluated first. The result is then divided by 2, and its result is added to 200.