SQL MCQs Interview Questions

0
SQL MCQs
SQL MCQs Interview Questions
SQL MCQs Interview Questions

20 MCQs Questions For Structured Query Language (SQL)

Q1) Which statement is true for a PRIMARY KEY constraint?

A) Primary key defines a realtionship between two tables.

B) A table in SQL must have a primary key associated with it to uniquely identify its records.

C ) A table in SQL is indexed by default based on its primary key.

D) Primary key may or may not be unique but can be comprised of multiple fields.

Show Answer
Answer :  (C) A table in SQL is indexed by default based on its primary key.

Q2) Which statement is false for a FOREIGN KEY constraint?

A) Foreign key defines a relationship between two tables.

B) Foreign Key is automatically created when two tables are joined.

C) Foreign Key uniquely identifies all the records in the referenced table.

D) Foreign key may or may not be unique but can be comprised of multiple fields.

Show Answer
Answer :  (B) Foreign Key is automatically created when two tables are joined.

Q3) What does SQL stand for?

A) Structured Question Language.

B) Strong Query Language.

C) Structured Query Language.

D) Strong Question Language.

Show Answer
Answer :  (C) Structured Query Language.

Q4) What is a Query?

A) A request for data from single or multiple tables in the database.

B) A SELECT or UPDATE statement in SQL.

C) A request for data from a table in the database.

D) A request to input data from the user.

Show Answer
Answer :  (A) A request for data from single or multiple tables in the database.

Q5) Query to select all records with "bar" in their name?

A) SELECT * FROM people WHERE name = "%bar%";

B) SELECT * FROM people WHERE name IN ("bar");

C) SELECT * FROM people WHERE name LIKE "%bar%";

D) SELECT * FROM people WHERE name = "%bar%";

Show Answer
Answer :  (C) SELECT * FROM people WHERE name LIKE "%bar%";

Q6) Which statement is used to update data in the database?

A) SAVE AS

B) ALTER TABLE

C) MODIFY

D) UPDATE

Show Answer
Answer :  (D) UPDATE

Q7) SQL query used to fetch unique values from a field?

A) SELECT UNIQUE column_name FROM table_name WHERE COUNT(column_name) = 1;

B) SELECT column_name FROM table_name WHERE COUNT(column_name) = 1;

C) SELECT UNIQUE column_name FROM table_name;

D) SELECT DISTINCT column_name FROM table_name;

Show Answer
Answer :  (D) SELECT DISTINCT column_name FROM table_name;

Q8) Which statement is false for the ORDER BY statement?

A) Can sort based on multiple columns

B) Requires a ASC or DESC keyword explicitly to sort the result set.

C) Sorts the result set in descending order using the DESC keyword.

D) None of the above.

Show Answer
Answer :  (B) Requires a ASC or DESC keyword explicitly to sort the result set.

Q9) What is the main advantage of a clustered index over a non-clustered index?

A) It is easier to create and manipulate.

B) It requires extra memory but allows for speedy retrieval of records.

C) It does not require additional memory and allows for speedy retrieval of records.

D) None of the above.

Show Answer
Answer :  (C) It does not require additional memory and allows for speedy retrieval of records.

Q10) Normalization which has neither composite values nor partial dependencies?

A) Boyce-Codd Normal Form

B) Third Normal Form

C) Second Normal Formal

D) All of the above

Show Answer
Answer :  (D) All of the above

Q11) Which of the following is known as a virtual table in SQL?

A) SELF JOIN

B) VIEW

C) INNER JOIN

D) NONE

Show Answer
Answer :  (B) VIEW

Q12) An SQL query to delete a table from the database and memory while keeping the structure of the table intact?

A) DROP FROM TABLE table_name;

B) TRUNCATE TABLE table_name;

C) DROP TABLE table_name;

D) DELETE FROM TABLE table_name;

Show Answer
Answer :  (B) TRUNCATE TABLE table_name;

Q13) What statement is used for adding data to PostgreSQL?

A) UPDATE

B) ADD

C) APPEND

D) INSERT

Show Answer
Answer :  (D) INSERT

Q14) What is the name of the component that requests data to the PostgreSQL server?

A) Interface

B) Workstation

C) Thin Client

D) Client

Show Answer
Answer :  (D) Client

Q15) What is the order of results shown by default if the ASC or DESC parameter is not specified with the ORDER BY command?

A) Results are shown in descending order

B) Results are shown in ascending order

C) Results display is random

D) Results are shown in ascending and descending order alternately.

Show Answer
Answer :  (B) Results are shown in ascending order

Q16) Which command is used to tell PostgreSQL to make all changes made to the database permanent?

A) Submit

B) Commit

C) Apply

D) Execute

Show Answer
Answer :  (B) Commit

Q17) What command is used for restoring the backup of PostgreSQL which was created using pg_dump?

A) psql -R db_dump.psql db_name

B) psql -r db_dump.psql db_name

C) psql -f db_dump.psql db_name

D) psql -F db_dump.psql db_name

Show Answer
Answer :  (B) psql -f db_dump.psql db_name

Q18) What is a pre-requisite for creating a database in PostgreSQL?To create a database in PostgreSQL, you must have the special CREATEDB privilege or

A) Super user privilege or CREATEDB privilege

B) Admin privilege

C) Just run the script

D) CREATEDBL privilege and Super user privilege

Show Answer
Answer :  (A) Super user privilege or CREATEDB privilege

Q19) What languages are supported by PostgreSQL?

A) PL/pgSQL, PL/Tcl, PL/Perl and PL/Python

B) Only SQL

C) PL/pgSQL, PL/Pcl, PL/Ruby and PL/Java

D) PL/Perl, PL/Dcl, PL/Dtl and PL/Dml

Show Answer
Answer :  (A) PL/pgSQL, PL/Tcl, PL/Perl and PL/Python

Q20) What allows us to define how various tables are related to each other formally in a database?

A) Views

B) Database manager

C) Primary Key Constraints

D) Foreign Key Constraints

Show Answer
Answer :  (D) Foreign Key Constraints
Tags

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
✨ Updates