SQL Flashcards

The SQL Interview Flashcards present key SQL topics, aiding users in quick recall, deeper understanding, and effective preparation for interviews or assessments. This resource facilitates efficient review and reinforcement of key SQL topics, fostering enhanced understanding, retention, and confidence for interview scenarios or practical application.
  • To-Do
    51 Flashcards
  • Done
    0 Flashcards
  • Start Over
    Reset All Flashcards
Flashcard
What is the output of the following query?
SELECT 25%5
Show Answer

0
Flashcard
What is a Cartesian product in SQL?
Show Answer

The result set that contains all ordered pairs of rows (x, y) for which x belongs to Table1 and y belongs to Table2

SELECT a.*, b.*
FROM table_name a, table_name b;
Flashcard
What Function Would You Use To Replace one string with a Different string In PostgreSQL?
Show Answer

REPLACE()
Flashcard
What function would you use to replace a character in a string with a different character in PostgreSQL?
Show Answer

TRANSLATE()
Flashcard
You would use the UNION ALL operator if you wanted to do what?
Show Answer

Combine two or more result sets without eliminating duplicate rows.
Flashcard
What does the UNION clause do?
Show Answer

Combine two or more result sets while eliminating duplicate rows.
Flashcard
What is the EXCEPT clause used for?
Show Answer

Returns those records from one SELECT query, that are not present in the results returned by the second SELECT query.

SELECT * FROM Table1
EXCEPT
SELECT * FROM Table2;
Flashcard
What is the largest numeric value that can be stored in a column with a BYTE datatype?
Show Answer

255
Flashcard
Can you update a VIEW in PostgreSQL?
Show Answer

No
Flashcard
What does the ACID acronym refer to?
Show Answer

ACID refers to the four key properties of a SQL transaction: atomicity, consistency, isolation, and durability.
Flashcard
What Is the Order of Execution of an SQL Query?
Show Answer

1st - FROM
2nd - ON
3rd - OUTER
4th - WHERE
5th - GROUP BY
6th - HAVING
7th - SELECT
8th - DISTINCT
9th - ORDER BY
10th - TOP
Flashcard
What is the output of the following query?
SELECT FLOOR(6.826)
Show Answer

6
Flashcard

What Is the Difference Between the WHERE and HAVING Clauses in SQL?

Show Answer

The WHERE Clause is used to filter the records of a table based on a specific condition. The HAVING Clause is used to filter the records resulting from an aggregate function query. HAVING clause is used to filter the record from the groups based on the specified condition.

Flashcard
How do you add comments to a SQL query?
Show Answer

-- This is a single line comment

/*
This is a
multiline comment
*/
Flashcard
What is the difference between the DROP and TRUNCATE clauses in SQL?
Show Answer

The DROP clause is used to drop an existing table in a database.

The TRUNCATE clause is used to delete the data inside an existing table, but not the table itself.
Flashcard
What function would you use to get the last n characters of a string column in PostgreSQL?
Show Answer

RIGHT(column_name, n)
Flashcard
What Is the Difference Between the GROUP BY and PARTITION BY clauses in SQL?
Show Answer

GROUP BY is used to calculate aggregate functions across the columns that are grouped by; the result set does not return all of the original records.

PARTITION BY is used to calculate aggregate functions for each record in the original table; the result set returns all of the original records.
Flashcard
How would you insert a new column into an existing table?
Show Answer

ALTER TABLE table_name
ADD column_name datatype;
Flashcard
What does the COALESCE function in SQL do?
Show Answer

The COALESCE function returns the first non-null argument in a list.
Flashcard
What is the syntax of a CASE statement?
Show Answer

CASE
WHEN condition1 THEN result1
WHEN condition2 THEN result2
WHEN conditionN THEN resultN
ELSE result
END;