SQL Basics (DQL + DML) Flashcards
SQL categories: DQL, DML, DDL, DCL, TCL SELECT, WHERE, ORDER BY, LIMIT INSERT, UPDATE, DELETE Aggregate functions: COUNT, SUM, AVG, MIN, MAX GROUP BY and HAVING JOINs: INNER, LEFT, RIGHT, FULL OUTER Aliases, DISTINCT, IS NULL vs = NULL (43 cards)
What are the main categories of SQL?
DQL (Data Query Language), DML (Data Manipulation Language), DDL (Data Definition Language), DCL (Data Control Language), TCL (Transaction Control Language).
What is DQL in SQL?
DQL is used to query data from the database, primarily using the SELECT statement.
What is DML in SQL?
DML includes commands like INSERT, UPDATE, DELETE to modify the data in the database.
What is DDL in SQL?
DDL is used to define and modify database structures, such as CREATE, ALTER, DROP.
What is DCL in SQL?
DCL includes commands like GRANT and REVOKE to control access to data.
What is TCL in SQL?
TCL includes commands like COMMIT, ROLLBACK, SAVEPOINT to manage transactions.
What does the SELECT statement do?
SELECT retrieves data from one or more tables.
What does the WHERE clause do in SQL?
WHERE filters rows based on specified conditions.
What does ORDER BY do?
ORDER BY sorts the result set based on one or more columns.
What does the LIMIT clause do?
LIMIT restricts the number of rows returned in a result set.
What does INSERT do in SQL?
INSERT adds new rows to a table.
What does UPDATE do in SQL?
UPDATE modifies existing rows in a table.
What does DELETE do in SQL?
DELETE removes rows from a table.
What does COUNT() do in SQL?
COUNT() returns the number of rows matching a condition.
What does SUM() do in SQL?
SUM() returns the total sum of a numeric column.
What does AVG() do in SQL?
AVG() returns the average value of a numeric column.
What does MIN() do in SQL?
MIN() returns the smallest value in a column.
What does MAX() do in SQL?
MAX() returns the largest value in a column.
What does GROUP BY do?
GROUP BY groups rows that have the same values into summary rows.
What does HAVING do?
HAVING filters groups based on aggregate conditions.
What is an INNER JOIN?
Returns rows with matching values in both tables.
What is a LEFT JOIN?
Returns all rows from the left table and matched rows from the right table.
What is a RIGHT JOIN?
Returns all rows from the right table and matched rows from the left table.
What is a FULL OUTER JOIN?
Returns all rows when there is a match in either left or right table.