Podcast
Questions and Answers
What is the effect of the following SQL code snippet?
What is the effect of the following SQL code snippet?
- Performs an undo operation on the delete operation.
- Deletes a row from the customer table where id equals 1.
- Both A and B (correct)
- None of the above
Regarding performance, which SQL statement is generally faster?
Regarding performance, which SQL statement is generally faster?
- UNION
- Both have the same performance
- UNION ALL (correct)
- None
What is the output of the SQL query select * from employees where rownum = 5;
?
What is the output of the SQL query select * from employees where rownum = 5;
?
- No rows selected. (correct)
- Prints the records of the 1st to 5th rows from the employee's table.
- SQL query error.
- Prints the record of the 5th row from the employee's table.
Which command is used to search for NULL
values in SQL?
Which command is used to search for NULL
values in SQL?
What is it called when multiple columns are collectively used as the Primary Key?
What is it called when multiple columns are collectively used as the Primary Key?
What will be the output of the following SQL command?
What will be the output of the following SQL command?
If Select count(product_id) from order;
returns 15, what is the maximum possible number of outputs for the query Select count(distinct product_id) from order;
?
If Select count(product_id) from order;
returns 15, what is the maximum possible number of outputs for the query Select count(distinct product_id) from order;
?
Which SQL keyword is used to combine the results of two or more SELECT
statements?
Which SQL keyword is used to combine the results of two or more SELECT
statements?
Which SQL JOIN
type returns all records from the left table and matching records from the right table?
Which SQL JOIN
type returns all records from the left table and matching records from the right table?
Which SQL keyword is used to retrieve data from a database table?
Which SQL keyword is used to retrieve data from a database table?
Which SQL statement is used to permanently save changes to the database?
Which SQL statement is used to permanently save changes to the database?
In SQL, which operator is used to check for matching values in a specified list?
In SQL, which operator is used to check for matching values in a specified list?
Which of the following commands is equivalent to the query Select e.name, d.name from employees e join departments d on e.department_id = d.department_id;
?
Which of the following commands is equivalent to the query Select e.name, d.name from employees e join departments d on e.department_id = d.department_id;
?
Which of the following is a single-row function in SQL?
Which of the following is a single-row function in SQL?
What will be the output of the following function? select substr('helloworld', -1, instr('helloworld', 'I', 3, 2)) from dual;
What will be the output of the following function? select substr('helloworld', -1, instr('helloworld', 'I', 3, 2)) from dual;
SQL Aggregate functions always return how many values?
SQL Aggregate functions always return how many values?
We can use a literal in the CONCAT function. What does literal refer to?
We can use a literal in the CONCAT function. What does literal refer to?
Which symbol represents the concatenation operator in SQL?
Which symbol represents the concatenation operator in SQL?
Which of the following queries finds the total number of employees working on 'HR' departments?
Which of the following queries finds the total number of employees working on 'HR' departments?
Which of the following queries finds the total rating of sailors who have reserved boat 103?
Which of the following queries finds the total rating of sailors who have reserved boat 103?
Flashcards
Delete and Rollback
Delete and Rollback
The code snippet attempts to delete a row from the 'customer' table where the 'id' is 1, and then rolls back, effectively undoing the deletion.
UNION vs. UNION ALL
UNION vs. UNION ALL
UNION ALL is faster because it does not remove duplicate rows, unlike UNION.
SQL ROWNUM
SQL ROWNUM
The query will return no rows because rownum
starts at 1, and the condition rownum = 5
can never be true during the initial rownum assignment.
Search for NULL values
Search for NULL values
Signup and view all the flashcards
Composite Key
Composite Key
Signup and view all the flashcards
Aggregate Function Error
Aggregate Function Error
Signup and view all the flashcards
Count Distinct
Count Distinct
Signup and view all the flashcards
Combine SELECT statements
Combine SELECT statements
Signup and view all the flashcards
LEFT JOIN
LEFT JOIN
Signup and view all the flashcards
Retrieve data
Retrieve data
Signup and view all the flashcards
Permanent Database changes
Permanent Database changes
Signup and view all the flashcards
Check for Matching Values
Check for Matching Values
Signup and view all the flashcards
Equivalent query
Equivalent query
Signup and view all the flashcards
Single-row function
Single-row function
Signup and view all the flashcards
Following Function Output
Following Function Output
Signup and view all the flashcards
SQL Aggregate function return values
SQL Aggregate function return values
Signup and view all the flashcards
Literal in concat
Literal in concat
Signup and view all the flashcards
What is the symbol of Concatenation Operator?
What is the symbol of Concatenation Operator?
Signup and view all the flashcards
total number of employees working on 'HR' departments?
total number of employees working on 'HR' departments?
Signup and view all the flashcards
total rating of the sailors who have reserved boat 103
total rating of the sailors who have reserved boat 103
Signup and view all the flashcards
Study Notes
-
DELETE FROM customer WHERE id = 1; ROLLBACK;
performs a delete operation and then attempts to undo it. -
The code snippet deletes a row from the customer table where the
id
is 1, then attempts to rollback the operation. -
UNION ALL
is faster thanUNION
in terms of performance. -
SELECT * FROM employees WHERE rownum = 5;
will yield no rows selected. -
The command to search for
NULL
values isIS NULL
. -
When multiple columns collectively act as the Primary Key, it is referred to as a Composite Key.
SQL Command Output
-
The command below will result in an error because a group function is not allowed in the
WHERE
clause.SELECT department_id, AVG(salary) FROM employees WHERE AVG(salary) > 8000 GROUP BY department_id;
-
If
SELECT count(product_id) FROM order;
gives 15 outputs, thenSELECT count(DISTINCT product_id) FROM order;
will give <= 15 outputs. -
The SQL keyword used to combine the results of two or more
SELECT
statements isUNION
. -
LEFT JOIN
returns all records from the left table and matching records from the right table. -
The SQL keyword used to retrieve data from a database table is
SELECT
. -
The SQL statement used to make permanent changes to the database is
COMMIT
. -
In SQL, the operator used to check for matching values in a specified list is
IN
.
Select e.name, d.name
FROM employees e
JOIN departments d
ON e.department_id = d.department_id;
- The command above is equivalent to the command below
Select e.name, d.name
FROM employees e
NATURAL JOIN departments d;
Concat
is a single-row function.
select substr('helloworld', -1, instr('helloworld', 'I', 3, 2)) from dual;
-
The output of the SQL function above is
d
. -
SQL Aggregate functions always return single values.
-
In the
CONCAT
function, a literal can refer to a number, character, or date. -
||
is the symbol for the Concatenation Operator. -
The query below finds the total number of employees working in 'HR' departments.
select count(*)
from employees
where department_id = (
Select id
from departments
where name = 'HR'
);
- The query below finds the total rating of the sailors who have reserved boat 103
SELECT SUM(s.rating)
FROM sailors s, reserves r
WHERE s.sid = r.sid AND r.bid = 103;
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.