Practice Test

The SQL “SELECT DISTINCT” statement queries only unique values from the database.

  • A) True
  • B) False

Answer: A) True

Explanation: The “SELECT DISTINCT” statement in SQL ensures that the fetched data points are all unique and do not duplicate any existing values.

Use of the SQL “AND” command can fetch results based on two or more conditions at the same time.

  • A) True
  • B) False

Answer: A) True

Explanation: The SQL “AND” operator is used to display records if both (or all) of the conditions separated by AND are TRUE. It combines multiple conditions.

The SQL “ORDER BY” statement is used for sorting data in descending order only.

  • A) True
  • B) False

Answer: B) False

Explanation: The SQL “ORDER BY” statement sorts the data in ascending order by default. If you want to sort the results in descending order, you can use the DESC keyword.

A subquery in SQL can only be used inside the WHERE clause.

  • A) True
  • B) False

Answer: B) False

Explanation: A subquery can be used in the SELECT, INSERT, UPDATE, or DELETE statement or inside another subquery.

SQL “BETWEEN” operator selects values within a given range. The values can be numbers, text, or dates.

  • A) True
  • B) False

Answer: A) True

Explanation: The “BETWEEN” operator in SQL is used to filter the result set within a certain range. The values can be numbers, text, or dates.

SQL language contains three types of SQL statements.

  • A) True
  • B) False

Answer: B) False

Explanation: SQL contains four types of SQL statements: DDL, DML, DCL, and TCL.

Which of the following is not a set operator?

  • A) UNION
  • B) INTERSECT
  • C) JOIN
  • D) MINUS

Answer: C) JOIN

Explanation: UNION, INTERSECT, and MINUS are all set operators. JOIN is used to combine rows from two or more tables based on a related column.

What does the SQL “HAVING” statement do?

  • A) Selects from a database
  • B) Updates a database
  • C) Acts like a WHERE clause but on groups
  • D) None of the above

Answer: C) Acts like a WHERE clause but on groups

Explanation: HAVING is used in combination with GROUP BY to filter groups based on a certain condition.

In SQL, _________ Clause is used for sorting.

  • A) SELECT
  • B) UPDATE
  • C) ORDER BY
  • D) FROM

Answer: C) ORDER BY

Explanation: ORDER BY in SQL is used to sort the data in ascending or descending order, based on one or more columns.

What does the SQL “LIKE” operator do?

  • A) Compares two strings for equality
  • B) Returns TRUE if the operand is within the range
  • C) Searches for a specified pattern in a column
  • D) Compares a column to a specified value

Answer: C) Searches for a specified pattern in a column

Explanation: The “LIKE” operator in SQL is used within a WHERE clause to search for a specified pattern in a column.

Interview Questions

What SQL command is typically used to extract data from a database in AWS?

The SELECT command is typically used to extract data from a database in AWS.

What does the SQL COUNT function do?

The SQL COUNT function returns the number of rows that matches a specified criterion.

Can you write a SQL query to create a new table in AWS RDS?

Yes, you can create a new table in AWS RDS using the CREATE TABLE statement. Here is an example:

CREATE TABLE Employees (
ID int,
Name varchar (255),
Age int,
Address varchar (255),
Salary decimal (18, 2));

How can you alter an existing AWS RDS table using SQL?

The ALTER TABLE statement is used to add, delete/drop or modify columns in an existing RDS table. For example, to add a column you can use the following SQL command:

ALTER TABLE table_name ADD column_name datatype;

What is the purpose of the SQL JOIN statement?

The SQL JOIN statement is used to combine rows from two or more tables, based on a related column between them, essentially allowing you to query data from multiple tables as one source.

Can you mention a SQL command to delete a table from AWS RDS?

Yes, the SQL command to delete a table from AWS RDS is DROP TABLE followed by the name of the table:

DROP TABLE table_name;

What is a subquery in SQL and where can it be used?

A subquery is a query that is embedded within the WHERE or HAVING clause of another SQL query. It can be used to return data that will be used in the main query as a condition to further restrict the data to be retrieved.

Can you rename a column in an existing AWS RDS table using SQL? If yes, how?

Yes, you can rename a column in an AWS RDS table using SQL. You would use the ALTER TABLE statement followed by the RENAME COLUMN command. Here’s an example:

ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;

How can you delete data from an AWS RDS table using SQL?

You can delete data from an AWS RDS table using the DELETE statement. For example:

DELETE FROM table_name WHERE condition;

What is the purpose of the SQL GROUP BY statement?

The SQL GROUP BY statement groups rows that have the same values in specified columns into aggregated data, like sum, average or count.

How would you insert data into an AWS RDS table using SQL?

You can insert data into an AWS RDS table by using the INSERT INTO statement. Here is an example:

INSERT INTO table_name (column1, column2, column3) VALUES (value1, value2, value3);

What is the purpose of the SQL UPDATE statement?

The SQL UPDATE statement is used to modify the existing records in a table.

What is the ORDER BY keyword used for in SQL?

The ORDER BY keyword is used in SQL to sort the result-set in ascending or descending order based on one or more columns.

How can you select distinct values from a column in AWS RDS using SQL?

You can select distinct values from a column in AWS RDS using the DISTINCT keyword. For example:

SELECT DISTINCT column_name FROM table_name;

What is the purpose of the WHERE clause in SQL?

The WHERE clause in SQL is used to filter records that fulfill a specified condition.

Leave a Reply

Your email address will not be published. Required fields are marked *