SQL Fundamentals

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Which of the following is a Relational Database Management System (RDBMS)?

  • MySQL
  • Oracle
  • Microsoft Access
  • All of the above (correct)

What is the most common SQL statement used to retrieve data from a database?

  • UPDATE
  • SELECT (correct)
  • CREATE
  • INSERT

Which data type in SQL would you choose to store a specific date, such as 'July 4, 1776'?

  • INT
  • FLOAT
  • VARCHAR
  • DATE (correct)

When constructing a query, which clause is used to specify a condition that filters the rows returned?

<p>WHERE (D)</p> Signup and view all the answers

What is the fundamental operation performed by a JOIN clause in SQL queries?

<p>Combines data from two or more tables (B)</p> Signup and view all the answers

Which SQL keyword is employed to consolidate the result sets of two SELECT statements into a single result set?

<p>UNION (D)</p> Signup and view all the answers

Which SQL command is used to permanently remove a table and all its data from a database?

<p>DROP TABLE (B)</p> Signup and view all the answers

Which aggregate function in SQL would you use to determine the total number of rows in a table, including those with NULL values?

<p>COUNT (B)</p> Signup and view all the answers

What operator is most commonly used within a WHERE clause to perform equality checks and comparisons of values?

<p>= (C)</p> Signup and view all the answers

What is the primary effect of using the DISTINCT keyword in a SELECT statement?

<p>Returns only unique values (A)</p> Signup and view all the answers

What key distinction differentiates an INNER JOIN from an OUTER JOIN in SQL?

<p>INNER JOIN returns all matching rows, while OUTER JOIN returns all rows from one table. (A)</p> Signup and view all the answers

What critical role does a primary key serve within a database table?

<p>To uniquely identify each row in a table (A)</p> Signup and view all the answers

How does the ORDER BY clause affect the output of a SELECT statement?

<p>Sorts the results (B)</p> Signup and view all the answers

What fundamentally differentiates the UPDATE statement from the DELETE statement in SQL?

<p>UPDATE modifies existing data, while DELETE removes data entirely (B)</p> Signup and view all the answers

What is the defining characteristic of a subquery in SQL?

<p>A query nested within another (A)</p> Signup and view all the answers

Which SQL statement demonstrates the correct syntax for creating a new table named 'Customers' with columns for 'CustomerID' (INT) and 'Name' (VARCHAR(255))?

<p>CREATE TABLE table_name (column1 datatype, column2 datatype, ...); (B)</p> Signup and view all the answers

Which of the following functions in SQL operates on each row individually, rather than on a group of rows?

<p>All of the above (D)</p> Signup and view all the answers

In a WHERE clause, what type of operation does the LIKE operator perform?

<p>Performs a pattern matching search (A)</p> Signup and view all the answers

What is the primary role of the GROUP BY clause in a SELECT statement?

<p>Groups data based on one or more columns (C)</p> Signup and view all the answers

What does an alias represent in an SQL context?

<p>A temporary name assigned to a table or column (B)</p> Signup and view all the answers

Flashcards

What is a RDBMS?

A system for managing relational databases.

What does SELECT do?

Used to retrieve data from a database.

What is the DATE datatype?

Best suited for storing dates.

What is the WHERE clause?

Specifies conditions in a SELECT statement.

Signup and view all the flashcards

What does JOIN do?

Combines data from two or more tables.

Signup and view all the flashcards

What does UNION do?

Combines the results of multiple SELECT statements.

Signup and view all the flashcards

What does DROP TABLE do?

Permanently deletes a table.

Signup and view all the flashcards

What does COUNT do?

Counts the number of rows in a table.

Signup and view all the flashcards

What does DISTINCT do?

Returns only unique values.

Signup and view all the flashcards

What is a subquery?

A query nested inside another query.

Signup and view all the flashcards

What is a database schema?

A blueprint for the database structure.

Signup and view all the flashcards

What is an alias?

A temporary name for a table or column.

Signup and view all the flashcards

What does foreign key do?

Establishes relationships between tables.

Signup and view all the flashcards

What does HAVING do?

Filters groups based on aggregate functions.

Signup and view all the flashcards

What distinguishes UNION?

Removes duplicates from combined results.

Signup and view all the flashcards

UPDATE vs DELETE?

Modifies data, DELETE removes data.

Signup and view all the flashcards

What is LIKE?

Like Wildcard searches.

Signup and view all the flashcards

True about TCL?

Transactions saved or reverted.

Signup and view all the flashcards

SQL data types?

Data type format.

Signup and view all the flashcards

Count(*) displays?

Displays customer amount

Signup and view all the flashcards

Study Notes

  • MySQL, Oracle, and Microsoft Access are examples of Relational Database Management Systems (RDBMS).
  • SELECT statement is the most common SQL statement to retrieve data from a database.
  • DATE is the SQL data type best suited for storing dates.
  • WHERE clause specifies a condition in a SELECT statement.
  • JOIN operation combines data from two or more tables in SQL.
  • UNION keyword combines the results of two or more SELECT statements.
  • DROP TABLE command permanently deletes a table.
  • COUNT function counts the number of rows in a table.
  • The "=" operator is used for comparisons in the WHERE clause.
  • DISTINCT keyword returns only unique values in a SELECT statement.
  • INNER JOIN returns all matching rows, while OUTER JOIN returns all rows from one table.
  • A primary key uniquely identifies each row in a table.
  • ORDER BY clause sorts the results in a SELECT statement.
  • UPDATE modifies existing data, while DELETE removes data entirely.
  • A subquery is a query nested within another.
  • CREATE TABLE table_name (column1 datatype, column2 datatype, ...) is the syntax for creating a new table in SQL.
  • Concat, lower and upper are examples of single-row functions.
  • The LIKE operator performs a pattern matching search in a WHERE clause.
  • GROUP BY clause groups data based on one or more columns.
  • An alias is a temporary name assigned to a table or column.
  • A foreign key create a relationship between tables, enforcing referential integrity.
  • HAVING clause filters groups based on a condition applied to aggregate functions in a SELECT statement used with GROUP BY.
  • UNION removes duplicates, while UNION ALL keeps all rows.
  • The symbol || represents a concatenation operator.
  • UNION ALL is faster in terms of performance compared to UNION.
  • Schema is a blueprint for the database structure, defining tables and their relationships, whereas tables store the actual data.
  • Transactions can be saved to the database and rolled back using TCL commands in SQL.
  • COMMIT statement saves the changes made within a transaction.
  • ROLLBACK statement reverts all changes made within a transaction.
  • Data types in SQL is used to specify the format and range of allowed values for a column.
  • An inner join combines data from two tables, while a self-join joins a table to itself.
  • Logical operators combine conditions, while comparison operators evaluate expressions.
  • Functions in SQL is used to perform calculations or manipulations on data.
  • Aggregate functions operate on groups of data, returning a single value, while scalar functions operate on individual values.
  • "Select * from customer natural join order;" is equivalent to "Select * from customer join order on customer.customerid = order.customerid;".
  • SELECT * FROM student WHERE name LIKE 'r%'; retrieves all data from student table starting the name from letter 'r'.
  • SELECT * FROM customers; statement retrieves data from a table named "customers" and display all columns.
  • SELECT * FROM customers WHERE id > 10; filters the results in the "customers" table to only show customers with an ID greater than 10.
  • SELECT COUNT (*) FROM customers; SQL statement will display the number of customers in the "customers" table.
  • SELECT name FROM customers ORDER BY name; retrieves the names of all customers from the "customers" table, sorted alphabetically (ascending order) by their names.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

SQL Practice Questions PDF

More Like This

Relational Databases and SQL Quiz
5 questions
Introduction to SQL Concepts
10 questions
RDBMS Overview and Data Storage Methods
18 questions
Use Quizgecko on...
Browser
Browser