SQL Basics
- 39Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What does SQL stand for?
What does SQL stand for?
39 questions
- 1
What does SQL stand for?
- A
Simple Query Language
- B
Sequential Query Language
- C
Standard Query Language
- D
Structured Query Language
Correct answer
DStructured Query Language
Explanation
SQL is an acronym for Structured Query Language, used to communicate with databases.
- A
- 2
What is the primary purpose of SQL?
- A
To design user interfaces
- B
To manage operating systems
- C
To communicate with databases
- D
To create spreadsheets
Correct answer
CTo communicate with databases
Explanation
SQL is a language designed specifically for managing and querying data in relational databases.
- A
- 3
What does DBMS stand for?
- A
Data Basic Manipulation System
- B
Data Backup Management System
- C
Database Maintenance System
- D
Database Management System
Correct answer
DDatabase Management System
Explanation
DBMS stands for Database Management System, software that manages databases.
- A
- 4
Which of the following best describes a relational database?
- A
A database that uses unstructured data
- B
A database that stores data in a single table
- C
A database managed by a spreadsheet program
- D
A database with tables that are related to each other through keys
Correct answer
DA database with tables that are related to each other through keys
Explanation
Relational databases organize data into tables that are linked via primary and foreign keys.
- A
- 5
Which of the following is an example of a non-relational database?
- A
Oracle
- B
MySQL
- C
NoSQL
- D
PostgreSQL
Correct answer
CNoSQL
Explanation
NoSQL databases are non-relational, while the others are relational database management systems.
- A
- 6
In a database table, what is a record?
- A
A row
- B
A column
- C
A field
- D
A table
Correct answer
AA row
Explanation
A record is a single row in a table, containing data for each column.
- A
- 7
What are the four basic operations in SQL collectively called?
- A
QUAD
- B
CRUD
- C
FECT
- D
SQL
Correct answer
BCRUD
Explanation
CRUD stands for Create, Read, Update, Delete — the four fundamental database operations.
- A
- 8
Which of the following is NOT a relational database management system?
- A
Microsoft SQL Server
- B
MySQL
- C
NoSQL
- D
PostgreSQL
Correct answer
CNoSQL
Explanation
NoSQL is a type of non-relational database, not a specific RDBMS.
- A
- 9
What character must every SQL command end with in MySQL?
- A
Comma (,)
- B
Colon (:)
- C
Semicolon (;)
- D
Period (.)
Correct answer
CSemicolon (;)
Explanation
In MySQL, a semicolon signals the end of a command; otherwise the interpreter waits for more input.
- A
- 10
Which command is used to display all databases in MySQL?
- A
LIST DATABASES
- B
DISPLAY DATABASES
- C
GET DATABASES
- D
SHOW DATABASES
Correct answer
DSHOW DATABASES
Explanation
The SHOW DATABASES command lists all databases on the server.
- A
- 11
What does the USE command do in MySQL?
- A
Selects a database to work with
- B
Shows the current database
- C
Deletes a database
- D
Creates a new database
Correct answer
ASelects a database to work with
Explanation
The USE command sets the active database for subsequent commands.
- A
- 12
How do you access the MySQL prompt after installation on Linux (as shown in the video)?
- A
sudo mysql-server
- B
mysql
- C
sudo mysql
- D
mysql start
Correct answer
Csudo mysql
Explanation
The video used 'sudo mysql' to access the MySQL prompt with root privileges.
- A
- 13
Which command installs the MySQL server on Ubuntu?
- A
sudo apt install mysql-workbench
- B
sudo apt install mysql-server
- C
sudo apt install mysql
- D
sudo apt install mysql-client
Correct answer
Bsudo apt install mysql-server
Explanation
The correct package for the MySQL server is 'mysql-server'.
- A
- 14
How do you verify that the MySQL service is running?
- A
sudo systemctl enable mysql
- B
sudo systemctl start mysql
- C
sudo mysql status
- D
sudo systemctl status mysql
Correct answer
Dsudo systemctl status mysql
Explanation
The status command shows whether the service is active and running.
- A
- 15
Which command creates a new database named 'test_db'?
- A
MAKE DATABASE test_db;
- B
CREATE DATABASE test_db;
- C
ADD DATABASE test_db;
- D
NEW DATABASE test_db;
Correct answer
BCREATE DATABASE test_db;
Explanation
The correct syntax is CREATE DATABASE followed by the database name.
- A
- 16
When creating a table, what is the purpose of specifying a data type for each column?
- A
To define the kind of data that can be stored in that column
- B
To create an index on the column
- C
To determine the column's position in the table
- D
To set a default value for the column
Correct answer
ATo define the kind of data that can be stored in that column
Explanation
Data types restrict what values can be entered (e.g., INT for integers, VARCHAR for strings).
- A
- 17
Which data type would you use to store a whole number in MySQL?
- A
VARCHAR
- B
TEXT
- C
BOOLEAN
- D
INT
Correct answer
DINT
Explanation
INT is used for integer (whole number) values.
- A
- 18
What does VARCHAR(255) mean in a column definition?
- A
The column stores exactly 255 characters
- B
The column can store up to 255 characters of text
- C
The column is a boolean value
- D
The column stores numbers up to 255
Correct answer
BThe column can store up to 255 characters of text
Explanation
VARCHAR(n) stores variable-length strings with a maximum length of n characters.
- A
- 19
Which command provides information about the columns of a table?
- A
SHOW COLUMNS
- B
DESCRIBE table_name
- C
VIEW table_name
- D
DISPLAY table_name
Correct answer
BDESCRIBE table_name
Explanation
DESCRIBE (or DESC) lists column names, types, and other details for the specified table.
- A
- 20
What is the term for the structure that defines how a database is organized?
- A
Format
- B
Schema
- C
Blueprint
- D
Layout
Correct answer
BSchema
Explanation
A schema defines the tables, columns, data types, and relationships in a database.
- A
- 21
In a CREATE TABLE statement, how are column definitions separated?
- A
With periods
- B
With spaces
- C
With semicolons
- D
With commas
Correct answer
DWith commas
Explanation
Commas separate each column definition inside the parentheses.
- A
- 22
Which command is used to add new rows to a table?
- A
UPDATE
- B
INSERT INTO
- C
ADD INTO
- D
CREATE
Correct answer
BINSERT INTO
Explanation
INSERT INTO adds one or more rows to a table.
- A
- 23
In an INSERT INTO statement, how are the values listed?
- A
In square brackets
- B
In curly braces
- C
In quotes separated by spaces
- D
In parentheses after the VALUES keyword
Correct answer
DIn parentheses after the VALUES keyword
Explanation
The syntax is INSERT INTO table VALUES (value1, value2, ...);
- A
- 24
What does the UPDATE command do?
- A
Modifies existing records
- B
Adds new records
- C
Deletes records
- D
Creates a new table
Correct answer
AModifies existing records
Explanation
UPDATE changes the values of existing rows in a table.
- A
- 25
To delete specific rows from a table, which clause is used with DELETE FROM?
- A
ORDER BY
- B
WHERE
- C
LIMIT
- D
HAVING
Correct answer
BWHERE
Explanation
The WHERE clause specifies which rows to delete; without it, all rows are removed.
- A
- 26
When using UPDATE, which keyword specifies the new value for a column?
- A
SET
- B
INTO
- C
VALUE
- D
ASSIGN
Correct answer
ASET
Explanation
The SET keyword assigns new values to the specified columns.
- A
- 27
What happens if you omit the WHERE clause in a DELETE statement?
- A
All rows in the table are deleted
- B
The table itself is deleted
- C
An error occurs
- D
Only the first row is deleted
Correct answer
AAll rows in the table are deleted
Explanation
DELETE without a WHERE clause removes every row from the table.
- A
- 28
What does the asterisk (*) mean in a SELECT statement?
- A
Select distinct values
- B
Select only the first column
- C
Multiply the values
- D
Select all columns
Correct answer
DSelect all columns
Explanation
SELECT * returns all columns from the specified table.
- A
- 29
Which clause is used to filter rows in a SELECT statement?
- A
HAVING
- B
IF
- C
WHERE
- D
FILTER
Correct answer
CWHERE
Explanation
The WHERE clause specifies conditions that rows must meet to be included in the result.
- A
- 30
How do you select only the 'name' column from a table called 'coffee'?
- A
SELECT name FROM coffee;
- B
SELECT * FROM coffee WHERE name;
- C
SELECT coffee.name;
- D
SELECT column name FROM coffee;
Correct answer
ASELECT name FROM coffee;
Explanation
To select specific columns, list them after SELECT, separated by commas.
- A
- 31
Which operator combines multiple conditions in a WHERE clause when both must be true?
- A
AND
- B
XOR
- C
NOT
- D
OR
Correct answer
AAND
Explanation
AND requires all conditions to be true for a row to be included.
- A
- 32
How do you sort query results in ascending order?
- A
ORDER BY column_name DESC
- B
ORDER BY column_name ASC
- C
SORT BY column_name ASC
- D
ORDER column_name ASC
Correct answer
BORDER BY column_name ASC
Explanation
ORDER BY with ASC (ascending) sorts from smallest to largest.
- A
- 33
What does DESC stand for in an ORDER BY clause?
- A
Descending
- B
Descriptor
- C
Design
- D
Description
Correct answer
ADescending
Explanation
DESC sorts in descending order, from largest to smallest.
- A
- 34
Which query returns all rows from 'avengers' where origin is 'Earth' or 'Asgard'?
- A
Both a and c
- B
SELECT * FROM avengers WHERE origin = 'Earth' AND origin = 'Asgard';
- C
SELECT * FROM avengers WHERE origin IN ('Earth', 'Asgard');
- D
SELECT * FROM avengers WHERE origin = 'Earth' OR origin = 'Asgard';
Correct answer
ABoth a and c
Explanation
Both the OR operator and the IN clause can achieve this filter; AND would require both conditions which is impossible.
- A
- 35
What command is used to add a new column to an existing table?
- A
MODIFY TABLE table_name ADD column_name data_type;
- B
ALTER TABLE table_name ADD column_name data_type;
- C
UPDATE TABLE table_name ADD column_name data_type;
- D
CHANGE TABLE table_name ADD column_name data_type;
Correct answer
BALTER TABLE table_name ADD column_name data_type;
Explanation
ALTER TABLE with ADD clause adds a new column to the table structure.
- A
- 36
In the video, what data type is used for a boolean (true/false) column?
- A
BOOLEAN
- B
TINYINT
- C
BIT
- D
BOOL
Correct answer
ABOOLEAN
Explanation
The video used 'boolean' as the data type for the beard column.
- A
- 37
In a relational database, what is the role of a primary key?
- A
To index the table for performance
- B
To create a relationship between tables
- C
To uniquely identify each row in a table
- D
To define the data type of a column
Correct answer
CTo uniquely identify each row in a table
Explanation
A primary key uniquely identifies each record; it is a column or set of columns with unique values.
- A
- 38
What is a foreign key in a relational database?
- A
A key that is unique across the entire database
- B
A key that is optional for each table
- C
A key that links two tables together
- D
A key that is used for encryption
Correct answer
CA key that links two tables together
Explanation
A foreign key in one table references the primary key of another table, creating a relationship.
- A
- 39
What is the purpose of a JOIN in SQL?
- A
To combine rows from two or more tables based on a related column
- B
To delete records that match a condition
- C
To update records in a join table
- D
To insert data into multiple tables at once
Correct answer
ATo combine rows from two or more tables based on a related column
Explanation
JOINs allow you to retrieve data from multiple related tables in a single query.
- A

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