SQL Full Course Tutorial
- 39Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What does SQL stand for?
What does SQL stand for?
39 questions
- 1
What does SQL stand for?
- A
Sequential Query Language
- B
Standard Query Language
- C
Simple Query Language
- D
Structured Query Language
Correct answer
DStructured Query Language
Explanation
SQL stands for Structured Query Language, used to communicate with databases.
- A
- 2
Which CRUD operation corresponds to the SELECT keyword?
- A
Create
- B
Read
- C
Update
- D
Delete
Correct answer
BRead
Explanation
SELECT is used to retrieve data, which is the Read operation in CRUD.
- A
- 3
What type of SQL command is INSERT INTO?
- A
DCL (Data Control Language)
- B
DQL (Data Query Language)
- C
DDL (Data Definition Language)
- D
DML (Data Manipulation Language)
Correct answer
DDML (Data Manipulation Language)
Explanation
INSERT INTO is a DML command used to add data to existing tables.
- A
- 4
Which of the following is a characteristic of a data warehouse according to Bill Inmon?
- A
Subject-oriented
- B
Volatile
- C
Real-time
- D
Application-oriented
Correct answer
ASubject-oriented
Explanation
A data warehouse must be subject-oriented, non-volatile, integrated, and time-variant.
- A
- 5
In an ERD, what does the 'crow's foot' symbol indicate?
- A
Many-to-many relationship
- B
Zero or one relationship
- C
One-to-one relationship
- D
One-to-many relationship
Correct answer
DOne-to-many relationship
Explanation
The crow's foot symbol on a line in an ERD indicates a 'many' side, typically one-to-many relationship.
- A
- 6
What is the purpose of a primary key in a table?
- A
Link to another table
- B
Uniquely identify each row
- C
Store large data
- D
Speed up queries
Correct answer
BUniquely identify each row
Explanation
A primary key uniquely identifies each row in a table.
- A
- 7
Which SQL clause is used to filter rows before aggregation?
- A
GROUP BY
- B
WHERE
- C
HAVING
- D
ORDER BY
Correct answer
BWHERE
Explanation
WHERE filters rows before aggregation occurs.
- A
- 8
What does the DISTINCT keyword do in a SELECT statement?
- A
Limits the number of rows returned
- B
Sorts the result in ascending order
- C
Removes duplicate rows from the result
- D
Filters rows based on a condition
Correct answer
CRemoves duplicate rows from the result
Explanation
DISTINCT returns only unique rows, removing duplicates.
- A
- 9
Which wildcard character in SQL matches zero or more characters?
- A
?
- B
%
- C
- D
_
Correct answer
B%
Explanation
The percent sign (%) matches any sequence of zero or more characters in a LIKE pattern.
- A
- 10
What is the result of the expression 11 % 3?
- A
0
- B
2
- C
3
- D
1
Correct answer
B2
Explanation
The modulus operator returns the remainder: 11 divided by 3 is 3 remainder 2.
- A
- 11
Which aggregate function returns the most frequently occurring value?
- A
MODE
- B
MEDIAN
- C
AVG
- D
There is no built-in mode function
Correct answer
DThere is no built-in mode function
Explanation
SQL does not have a built-in MODE function; such calculations require additional logic.
- A
- 12
In a LEFT JOIN, which table's rows are all preserved?
- A
The left table (table A)
- B
Both tables
- C
Neither table
- D
The right table (table B)
Correct answer
AThe left table (table A)
Explanation
A LEFT JOIN preserves all rows from the left table (table A) and matches rows from the right table.
- A
- 13
What is a self-join?
- A
Joining with an alias
- B
Joining a table to itself
- C
Joining two identical tables
- D
Joining with no condition
Correct answer
BJoining a table to itself
Explanation
A self-join joins a table to itself, often using different aliases.
- A
- 14
Which SQL command is used to delete all rows from a table but keep the table structure?
- A
DELETE TABLE
- B
TRUNCATE TABLE
- C
REMOVE TABLE
- D
DROP TABLE
Correct answer
BTRUNCATE TABLE
Explanation
TRUNCATE TABLE removes all rows while preserving the table structure.
- A
- 15
What does the ALTER TABLE command do?
- A
Deletes a table
- B
Alters the data in a table
- C
Creates a new table
- D
Modifies the structure of an existing table
Correct answer
DModifies the structure of an existing table
Explanation
ALTER TABLE is used to add, drop, or modify columns in an existing table.
- A
- 16
Which of the following is a DDL command?
- A
UPDATE
- B
DROP TABLE
- C
DELETE
- D
INSERT INTO
Correct answer
BDROP TABLE
Explanation
DROP TABLE is a DDL command that removes a table structure and data.
- A
- 17
What does the COALESCE function do?
- A
Checks if any value is null
- B
Replaces null with a specified default
- C
Returns the first non-null value in a list of expressions
- D
Returns the last non-null value
Correct answer
CReturns the first non-null value in a list of expressions
Explanation
COALESCE returns the first non-null value among its arguments.
- A
- 18
What is the difference between UNION and UNION ALL?
- A
UNION ALL is faster but only works with numeric data
- B
UNION ALL removes duplicates; UNION keeps duplicates
- C
UNION sorts results; UNION ALL does not
- D
UNION removes duplicates; UNION ALL keeps duplicates
Correct answer
DUNION removes duplicates; UNION ALL keeps duplicates
Explanation
UNION eliminates duplicate rows while UNION ALL retains all rows including duplicates.
- A
- 19
In a window function, what does the PARTITION BY clause do?
- A
Divides rows into groups to which the function is applied separately
- B
Filters partitions based on a condition
- C
Orders rows within each partition
- D
Defines the window frame
Correct answer
ADivides rows into groups to which the function is applied separately
Explanation
PARTITION BY splits the result set into partitions, and the window function is applied to each partition individually.
- A
- 20
Which function is used to extract a specific part of a date, such as month or year?
- A
CAST
- B
EXTRACT
- C
DATE_PART
- D
DATE_TRUNC
Correct answer
BEXTRACT
Explanation
EXTRACT retrieves a specified part (like year, month) from a date/timestamp.
- A
- 21
What does the ROW_NUMBER() function do?
- A
Assigns a dense rank without gaps
- B
Assigns a rank with gaps for ties
- C
Assigns a unique sequential integer to each row within a partition
- D
Returns the number of rows in the result set
Correct answer
CAssigns a unique sequential integer to each row within a partition
Explanation
ROW_NUMBER() gives each row a unique number starting from 1 within each partition.
- A
- 22
In Git, what is the command to create a new branch and switch to it?
- A
git checkout -b
- B
git clone
- C
git switch
- D
git branch
Correct answer
Agit checkout -b
Explanation
git checkout -b creates a new branch and switches to it. (git switch -c is newer but functionally similar.)
- A
- 23
What is a pull request (PR) used for in GitHub?
- A
Pulling updates from a remote repository
- B
Proposing changes to a repository for review
- C
Pushing local changes to the remote
- D
Requesting to pull the latest changes from main
Correct answer
BProposing changes to a repository for review
Explanation
A pull request is a way to propose changes and request that they be merged into another branch.
- A
- 24
Which of the following is a case expression?
- A
CASE WHEN condition THEN result END
- B
CHOOSE(condition, result)
- C
IF condition THEN result
- D
SWITCH condition
Correct answer
ACASE WHEN condition THEN result END
Explanation
SQL uses CASE expression with WHEN-THEN-ELSE-END syntax.
- A
- 25
What type of join returns only rows where there is a match in both tables?
- A
RIGHT JOIN
- B
INNER JOIN
- C
LEFT JOIN
- D
FULL OUTER JOIN
Correct answer
BINNER JOIN
Explanation
INNER JOIN returns rows that have matching values in both tables.
- A
- 26
What is the purpose of the HAVING clause?
- A
Filter groups after aggregation
- B
Order the result set
- C
Filter rows before grouping
- D
Limit the number of groups
Correct answer
AFilter groups after aggregation
Explanation
HAVING is used to filter groups created by GROUP BY, not individual rows.
- A
- 27
Which command is used to initialize a Git repository in a project folder?
- A
git start
- B
git init
- C
git new
- D
git create
Correct answer
Bgit init
Explanation
git init creates a new Git repository in the current directory.
- A
- 28
What does the 'CASCADE' option in a DROP SCHEMA command do?
- A
Drops only the schema if empty
- B
Cascades the drop to other databases
- C
Drops the schema and all dependent objects
- D
Reverts the drop if it fails
Correct answer
CDrops the schema and all dependent objects
Explanation
CASCADE ensures that the schema and all objects within it (like tables) are dropped.
- A
- 29
What is a CTE (Common Table Expression)?
- A
A stored procedure that returns a table
- B
A permanent table created by a SELECT INTO statement
- C
A temporary named result set that exists within the scope of a single query
- D
A subquery in the FROM clause
Correct answer
CA temporary named result set that exists within the scope of a single query
Explanation
A CTE is defined using WITH and provides a temporary result set that can be referenced in the main query.
- A
- 30
In the terminal, what command lists files and directories in the current directory?
- A
list
- B
ls
- C
show
- D
dir
Correct answer
Bls
Explanation
The 'ls' command lists contents of a directory on Unix-based systems.
- A
- 31
What is the default branch name in Git after a fresh 'git init'?
- A
main
- B
master
- C
trunk
- D
default
Correct answer
Bmaster
Explanation
Historically, the default branch is named 'master'. Many platforms now use 'main' by default, but git init still creates 'master' unless configured otherwise.
- A
- 32
Which SQL function is used to round a numeric value to a specified number of decimal places?
- A
TRUNC
- B
CEIL
- C
ROUND
- D
FLOOR
Correct answer
CROUND
Explanation
ROUND rounds a number to the specified decimal places.
- A
- 33
What does the NULLIF function do?
- A
Returns NULL if the expression is NULL, otherwise the expression
- B
Checks if a value is NULL
- C
Replaces NULL with a default value
- D
Returns NULL if two expressions are equal, otherwise returns the first expression
Correct answer
DReturns NULL if two expressions are equal, otherwise returns the first expression
Explanation
NULLIF(expr1, expr2) returns NULL if expr1 equals expr2, else returns expr1.
- A
- 34
What is the purpose of a bridge table in a data warehouse?
- A
To provide a flat view of the data
- B
To resolve a many-to-many relationship between two tables
- C
To enforce referential integrity
- D
To store historical changes
Correct answer
BTo resolve a many-to-many relationship between two tables
Explanation
A bridge table sits between two tables with a many-to-many relationship, containing foreign keys from both.
- A
- 35
Which of the following best describes a 'factless fact table'?
- A
A table that only contains dates
- B
A fact table with all null measures
- C
A dimension table with no attributes
- D
A fact table containing no numeric measures, only foreign keys
Correct answer
DA fact table containing no numeric measures, only foreign keys
Explanation
A factless fact table records events but lacks measurable numeric columns; it contains only foreign keys.
- A
- 36
In DuckDB, what command is used to exit the interactive CLI?
- A
.quit
- B
END
- C
quit
- D
exit
Correct answer
A.quit
Explanation
The DuckDB CLI uses '.quit' to exit (or '.exit').
- A
- 37
What is the correct order of clauses in a SQL query (syntactically)?
- A
FROM, SELECT, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT
- B
WHERE, SELECT, FROM, GROUP BY, HAVING, ORDER BY, LIMIT
- C
SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT
- D
SELECT, FROM, GROUP BY, WHERE, HAVING, ORDER BY, LIMIT
Correct answer
CSELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT
Explanation
The correct syntactic order is SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT.
- A
- 38
Which statement about SQL's logical operator precedence is true?
- A
All are evaluated left to right
- B
AND is evaluated before OR, which is evaluated before NOT
- C
NOT is evaluated before AND, which is evaluated before OR
- D
OR is evaluated before AND
Correct answer
CNOT is evaluated before AND, which is evaluated before OR
Explanation
In SQL, NOT has highest precedence, then AND, then OR.
- A
- 39
What is the difference between CHAR and VARCHAR data types?
- A
CHAR stores Unicode; VARCHAR stores ASCII
- B
VARCHAR is fixed; CHAR is variable
- C
CHAR is numeric; VARCHAR is text
- D
CHAR has fixed length; VARCHAR has variable length
Correct answer
DCHAR has fixed length; VARCHAR has variable length
Explanation
CHAR(n) always uses n characters (padding with spaces), while VARCHAR(n) uses only as much space as needed.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.