SQL: Concepts, Vocab, Syntax Flashcards
(52 cards)
What does SQL stand for?
Structured Query Language
What is SQL used for?
To manage data held in relational database management systems (RDBMS)
What type of data does SQL work with?
Structured data with relations among variables
What are the main scopes of SQL?
- Data query
- Data manipulation
- Data definition
- Data access control
What happens if correct syntax is not used in SQL?
The SQL will return an error
What is the function of the SELECT clause in SQL?
To describe a set of data you want to retrieve from a database
What must be included in a SELECT statement?
- What tables contain the data
- How the data is related
- Which fields or calculations will produce the data
- Criteria for data inclusion
- Sorting order for results
What is the purpose of the FROM clause in SQL?
To identify the table where the fields specified in the SELECT clause are located
What is the most basic structure of a SELECT statement?
- SELECT clause
- FROM clause
How do you select all columns from a table in SQL?
Use the asterisk (*) symbol in the SELECT clause
What does the WHERE clause do?
Specifies criteria to filter or limit the query results
Is the WHERE clause required in a SELECT statement?
No, it is not a required element
What are the AND and OR operators used for in SQL?
To add additional clauses following the initial WHERE clause
What does the ORDER BY clause do?
Sorts query results based on specified fields
What is the default sorting order in SQL?
Ascending order
How do you specify descending order in SQL?
Use the DESC keyword
What is the purpose of the JOIN clause in SQL?
To combine rows from two or more tables based on a related column
What are the types of JOINs in SQL?
- INNER JOIN
- LEFT JOIN
- RIGHT JOIN
- FULL JOIN
What does an INNER JOIN do?
Returns records that have matching values in both tables
What does a LEFT JOIN return?
All records from the left table and matched records from the right table
What does a FULL JOIN return?
All records from both tables, with nulls in the columns where there are no matches
What is the UNION operator used for?
To combine the result-sets of two or more SELECT statements
What are the requirements for using the UNION operator?
- Same number of columns
- Compatible data types
- Same order of columns in each SELECT statement
What is a relationship in the context of SQL?
An association between common fields in two tables