Browse all practice questions for the SQL Basics Practice Test. Search by topic, open any question and review its full explanation, then test yourself in the practice quiz.

SQL Basics Practice Test course image
More practice questions

These questions are part of the practice quiz. Start practicing

  • Which term describes a fast-access structure that holds copies of original values and is not part of the SQL standard?
  • Which term refers to a data file with no relational structure among its records?
  • Which combination correctly starts a transaction and then commits it?
  • What is the effect of ORDER BY hire_date DESC in a query?
  • Which SQL operator tests for the existence of rows returned by a subquery?
  • Which operator would you use to compute the maximum numeric value in a column, ignoring NULLs?
  • Which SQL statement adds a new row to a table?
  • What term describes a set of rows of a certain entity-type, i.e., all rows share the same structure?
  • Which function returns the current date in many SQL dialects?
  • Which is the correct syntax to modify an existing table by adding a new column?
  • Operator that returns true if the value on the left is larger than the value on the right.
  • Which acronym represents the four properties of a database transaction?
  • Which property ensures that a transaction is fully completed or fully rolled back?
  • Which aggregate function returns the sum of values in a numeric column, excluding NULLs?
  • How do you ensure a column cannot contain NULL values at creation time?
  • Used to temporarily rename a column or a column heading.
  • How do you select a customer's total orders using a scalar subquery in the SELECT list?
  • Which statement would count the number of orders per customer using a GROUP BY clause?
  • How do you replace NULL with a default value for a column in a SELECT?
  • Which clause imposes conditions on the fields that are summarized in the SELECT statement?
  • In some SQL dialects, how can you handle NULL-safe equality checks in predicates?
  • Which language defines the logical and physical design of a database (for example, CREATE TABLE)?
  • How do you get sales between 100 and 500 inclusive?
  • Which clause or keyword is used to provide the list of values to insert into a table?
  • Which SQL statement queries data from a table?
  • Which principle states that completed transactions should remain stable/permanent even during system failure?
  • Which clause is used to filter groups after a GROUP BY based on a condition on aggregates?
  • What is the result of a CROSS JOIN between two tables?
  • Operator that returns true if the value on the left is less than or equal to the value on the right.
  • In DDL, how do you declare a column as the primary key?
  • Which clause specifies field criteria that must be met by each record to be included in the results?
  • What is the virtual table that contains only its definition and no real data, defined by a query over real tables?
  • Which query returns customers whose average order amount exceeds 100?
  • Which syntax assigns an alias to a table in the FROM clause?
  • How do you get the length of a string in many SQL dialects?
  • How do you count the number of orders per customer?
  • A data file that has no structured relationships between its records is known as a
  • Which query structure returns rows from customers where the id appears in the customer_id column of orders?
  • Which time format includes an optional fractional part?
  • How do you cast a string date '2020-01-01' to a DATE type?
  • Which property ensures transitions from one valid state to another valid state?
  • NULL is an example of which type of value that does not change?
  • Which SQL command would you issue to revert all uncommitted changes in the current transaction?
  • Which operator removes duplicates when combining results from two SELECT statements?
  • In SQL, a language element that is part of a statement is called a
  • Which statement creates a simple view named recent_orders showing orders from the last 30 days?
  • What are the three main stages of normalization collectively called?
  • How do you alias a table and a column in a SELECT?
  • A reference between two different or the same entity. Based upon the values of the entities.
  • Which qualifier returns only unique values in a result set?
  • Which concept defines the three boolean values SQL uses: TRUE, FALSE, and UNKNOWN?
  • In a JOIN, what clause specifies how rows from two tables are matched?
  • How do you return orders with customer details using an inner join between orders and customers on customer_id?
  • In storage terms, what is a mass storage structure that contains rows or tables called?
  • A combination of operands and operators that yields a value for use in a query is called a
  • Which database object points to a currently selected set of records and can be acted on as a group in many languages?
  • Which query selects records from tickets where (status = 'open' AND priority = 'high') OR (status = 'new')?
  • What is the term for a combination of identifiers, operators, constants and functions that evaluates to a single value?
  • How do you declare a foreign key referencing another_table(id)?
  • Which operation adds a new row to a table?
  • Which data type stores both date and time?
  • Which keyword is used to define a default value for a column in a DDL statement?
  • What term refers to a special type of stored procedure that executes automatically in response to events and is associated with a specific table?
  • In a many-to-many relationship, the rows of the junction table contain the primary keys of T1 and T2 as values.
  • Which description best defines a correlated subquery?
  • What term describes a name used to identify a database object, such as a field?
  • Which clause is used to filter rows in query results?
  • Which construct describes a non arithmetic condition such as NOT IN or NOT LIKE?
  • A construct containing copies of original values and backreferences to their original rows. Not part of the SQL standard.
  • Which aggregate function returns the average value for a numeric column, excluding NULLs?
  • Which term describes a key field that identifies records in a table by matching a primary key in a different table?
  • Which term describes a reference between two entities that depends on the values of the entities?
  • In 1NF, which property describes the indivisibility of each value in a column?
  • Which SQL statement creates a new table?
  • Which sequence begins a transaction and then commits it?
  • How do you sort employees by hire_date descending?
  • Operator that returns true if the value on the left is smaller than the value on the right.
  • Which term describes a relationship or connection between two entities that can be a part of data modeling and is based on the values of the entities?
  • Which operator returns true if the values on either side are equal to each other?
  • Which statement retrieves all columns from a table named orders?
  • Which clause returns unique values for a column in a SELECT statement?
  • Which SQL command cancels the proposed changes in a pending transaction and marks the end of the transaction?
  • What term refers to a virtual table defined by a query that references real tables?
  • Which normal form eliminates partial dependency of non-key attributes on the primary key?
  • Which term refers to a keyword that represents an action or modifies an action, typically a verb or adverb?
  • SQL operator that returns true when the value is NULL and false otherwise
  • In a relational database, a complete set of information presented in a table, with each row representing a single item, is called a
  • Which operator compares if the left value is greater than or equal to the right?
  • Which CASE expression assigns 'high' for score > 80, 'medium' for >=50, else 'low'?
  • An identifiable object like employee or department is an instance of which type?
  • How do you find products whose name starts with 'App'?
  • What is a common block comment notation used in many programming languages?
  • Which pattern returns customers whose id matches any customer_id in orders?
  • Which of the following creates a table with an inline primary key for id?
  • Which aggregate function returns the maximum value in a column, excluding NULLs?
  • Which operation returns only rows that appear in both result sets?
  • Which operator returns rows from the first query not present in the second query?
  • Which data type would you use to store text in a column?
  • Which construct defines higher-level rules for data items, including nullability and keys?
  • Which expression would you use to filter orders within the last 30 days relative to today?
  • What is the purpose of the CAST function?
  • Which data type is used to store strings with a specified maximum length?
  • What is the primary goal of normalization in a relational database?
  • In the hexadecimal number system, which characters are used to represent values 10-15?
  • Which language retrieves and manipulates data (for example, SELECT, INSERT, DELETE)?
  • Which SQL statement edits a row in a table?
  • How do you select rows where country is one of 'USA', 'Canada', or 'UK'?
  • Which ACID property ensures that a transaction is all-or-nothing?
  • In the time format HH:MM:SS[.sf], what does the part in brackets represent?
  • How do you return only the first 10 rows from a query in PostgreSQL/MySQL?
  • Which operation changes the structure of an existing table?
  • What does RDMS stand for?
  • Which notation denotes a multi-line comment?
  • Operator that returns true if the value on the left is greater than or equal to the value on the right.
  • Which data type is used to store date values in the format year-month-day?
  • Which operator checks for NULL values in a condition?
  • Which SQL statement changes an existing table?
  • How do you check if a customer has any orders using EXISTS?
  • Which term is a clause that indicates the column to edit?
  • Which clause lists the tables that contain the fields in the SELECT clause?
  • Which SQL statement retrieves all columns from a table named customers?
  • Which statement fragment is used to add a new column to an existing table?
  • Which operator returns true if the values on either side are not equal to each other?
  • Which operator checks for inequality (not equal) between two values?
  • How do you filter groups to those with more than 5 orders?
  • What term describes a single record in a table with exactly one value for each column?
  • Which data type stores variable-length character values?
  • Which statement creates an index on orders(customer_id) with the name idx_orders_customer_id?
  • Which identifier denotes descending order in a sort operation?
  • Which data type stores only the time of day without a date?
  • Which statement removes all rows from the table old_data but keeps the table structure?
  • What term describes a group of SQL statements that are executed as a single atomic unit?
  • Which data type is used to store binary data?
  • Which property ensures that concurrent transactions do not interfere with each other?
  • How do you concatenate first_name and last_name with a space in between?
  • What is the primary idea of First Normal Form (1NF) in relational databases?
  • Where is the DISTINCT qualifier placed in a SELECT statement?
  • A language element which specifies a non arithmetic condition Ex. [NOT] IN, [NOT] LIKE
  • Which term describes the fundamental unit of data that characterizes an entity, such as its datatype and size?
  • The three main stages of normalization are collectively known as what?
  • How do you find records where phone is not provided (NULL) in customers?
  • Which clause sets a default value for a column named status to 'active'?
  • Which query includes all orders and their customers, even if an order has no customer (rare scenario)?
  • Which statement creates an index on orders(customer_id) with the name idx_orders_customer_id?
  • How do you return unique city values from a table customers?
  • What format is described by 'YYYY-MM-DD' for dates?
  • Which aggregate function counts the number of non-null values in a column per group?
  • A group of attributes describing the structure of entities is called what?
  • Which term describes a constraint that holds a unique value identifying each record and may be composed of multiple fields?
  • A block whose content has changed memory, but is still not written to disk.
  • Which clause specifies how to sort the results of a query?
  • Which SQL command marks the finalization of a database transaction?
  • What is the term for a single data item located at the intersection of a row and a column?
  • How do you select first_name and last_name from employees and alias the column last_name as surname in the result?
  • Which aggregate function calculates the average value?
  • Intermediate table to store a relationship where more than one row of T1 refers to more than one row of T2.
  • Which data type is used to store binary data?
  • Which aggregate function returns the minimum value in a column, excluding NULLs?
  • What language defines the access rights to data?
  • Which normal form is defined as No duplicate information permitted; if two tables require a common field, that common field's information should be separated into a different table?
  • How do you include all customers and their orders, even if a customer has none?
  • Which statement creates a table named products with id as integer primary key and name as varchar(100) not null?
  • Is the data type for a column that indicates text
  • Which statement accurately describes First Normal Form as presented?
  • How do you extract the year from a date column named order_date?
  • Which symbol denotes a single-line comment in SQL-like syntax?
  • When using UNION to combine two SELECT statements, which condition must hold?
  • Which operator returns distinct results when combining two result sets?
  • Which operation is used to retrieve data by listing the fields to include?
  • Which term is a special stored procedure that automatically runs in response to events on a table?
  • What is a correlated subquery?
  • In relational database terminology, a value that does not change, such as a number or NULL, is called a ...
  • Which term is a clause that indicates the data being inserted?
  • Which SQL statement removes the table named old_data from the database?
  • What term describes an expression that evaluates to true or false?
  • In a database, which concept represents a single row within a table?
  • Which SQL statement deletes rows from a table? (Is a clause)
  • Which syntax limits the number of rows to 10 in PostgreSQL/MySQL?
  • Which statement counts only non-null values in a column?
  • Which statement describes INNER JOIN behavior?
  • Which database concept holds a unique value identifying each record and can be composed of multiple fields?
  • Which aggregate function returns the count of a column and includes NULL values when used with an asterisk?
  • What is the database system catalog that stores metadata about tables, views, and constraints?
  • Which data type stores fixed-length character values?
  • Which constraint enforces referential integrity by linking a column to a primary key in another table?
  • What term describes a property used to characterize data items of entities, such as datatype and size?
  • Which operator lets you combine two SELECT statements into one, requiring the same number of output fields in the same order?
  • Write a query to fetch all orders with status = 'shipped'.
  • Which qualifier returns all values by default?
  • Which term refers to the name of the table the command is applied to?
  • In SQL, which concept allows you to assign a temporary name to a column or expression in a query?
  • Which data type stores variable-length character values?
  • All queries begin with which command?
  • Is a clause that lets you add a new column to a table.
  • How do you add a new column email VARCHAR(255) to a table users?
  • Which concept refers to a group of SQL statements that are treated as a single unit of work, which either all succeed or fail?
  • Which operator checks if the left value is less than or equal to the right?
  • Which keyword sorts values in descending order?
  • Which term describes a virtual table that presents data as a table but does not store its own data?
  • In the numeral system using digits 0-9 and letters A-F, which system is described?
  • What is the difference between COUNT(*) and COUNT(column_name) when counting rows with NULLs?
  • Which clause lists the fields that are not summarized in the SELECT clause when using aggregate functions?
  • Which mechanism allows rows of a table to be acted on at one time?
  • In a relational table, what is the smallest unit of data?
  • Which operator would you use to compute the total numeric value of a column, ignoring NULLs?
  • Which statement describes a scalar subquery in the SELECT clause?
Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy