0% found this document useful (0 votes)
132 views14 pages

SQL Commands

The document contains 40 multiple choice questions about SQL concepts like data types, DDL and DML commands, joins, aggregates and more. It provides the question, multiple choice answers and an explanation for the correct answer. The questions cover a wide range of fundamental SQL topics to test one's knowledge of the language.

Uploaded by

Sumit Dharmarao
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
132 views14 pages

SQL Commands

The document contains 40 multiple choice questions about SQL concepts like data types, DDL and DML commands, joins, aggregates and more. It provides the question, multiple choice answers and an explanation for the correct answer. The questions cover a wide range of fundamental SQL topics to test one's knowledge of the language.

Uploaded by

Sumit Dharmarao
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 14

1.

 
Which of the following are some common RDBMS in use?
Oracle
MySQL
HeidiSQL
All of the above
Hide
Wrong Answer
Explanation: All of the above options are examples of some famous RDBMS in use.
2. 
What command is used to create a new table in SQL?
CREATE TABLE
BUILD TABLE
GENERATE TABLE
None of the above
Hide
Correct Answer
Explanation: The CREATE TABLE command is used to create a new table in SQL.
3. 
What does the following statement in SQL do?
DROP TABLE student;
Deletes a table called student.
Creates a table called student.
Check if there is a table called student.
None of the above.
Hide
Correct Answer
Explanation: The DROP command is used to delete/drop a table in SQL.
4. 
Which of the following are types of Unicode character string types in SQL?
nchar
ntext
Both A and B
None of the above
Hide
Wrong Answer
Explanation: nchar and ntext are types of Unicode character strings datatypes in SQL.
5. 
What does BLOB in SQL stand for?
Binary Large Objects
Big Large Objects
Binary Language for Objects
None of the above
Hide
Correct Answer
Explanation: BLOB in SQL stands for Binary Large Objects which is an SQL Object
datatype.
6. 
Which of the following datatype is most appropriate for storing a string of up to 255
characters?
TEXT
TINY TEXT
BLOB
BINARY
Hide
Wrong Answer
Explanation: TINY TEXT can contain a string of up to 255 characters or 255 bytes.
7. 
What happens when no value is inserted in an ENUM list?
Nothing happens
The code will crash
A blank value is inserted in that case
None of the above
Hide
Wrong Answer
Explanation: In the case an ENUM list is empty and no value is inserted, a blank value
is inserted in the list.
8. 
What is the range of integers that can be held in the MEDIUMINT datatype of SQL?
Signed numbers in the range of -8388608 to 8388607.
Unsigned numbers in the range of 0 to 16777215.
Both A and B.
None of the above.
Check Answer
9. 
What does the following code snippet do?
ALTER TABLE STUDENT ADD(ADDRESS VARCHAR2(20));
Adds a column called ADDRESS in the table student.
Checks if a column called ADDRESS is present in the table student.
Invalid Syntax
None of the above
Hide
Correct Answer
Explanation: The ADD command is used to add a new column with given
specifications into a table by altering the contents of the table.
10. 
Which of the following commands is used to delete all rows and free up space from a
table?
TRUNCATE
DROP
DELETE
ALTER
Hide
Wrong Answer
Explanation: TRUNCATE command is used to delete all rows and free up space from a
table.
11. 
Which of the following commands are a part of Data Control Language?
Revoke
Grant
Both A and B
None of the above
Hide
Correct Answer
Explanation: Revoke and Grant are the 2 commands that are a part of Data Control
Language.
12. 
What does the following code snippet do?
DELETE FROM STUDENTS
WHERE AGE = 16;
ROLLBACK;
Performs an undo operation on the delete operation.
Deletes the rows from the table where AGE = 16
Deletes the entire table
None of the above
Hide
Correct Answer
Explanation: The ROLLBACK command is used to perform a rollback onto the latest
unsaved changes.
13. 
When is the wildcard in WHERE clause used?
An exact match is necessary for a CREATE statement.
An exact match is not possible in a SELECT statement.
An exact match is necessary for a SELECT statement.
None of the above.
Hide
Wrong Answer
Explanation: Wildcard in WHERE clause is used when an exact match is not possible in
a SELECT statement.
14. 
Which of the following is the full form of DDL?
Data definition language
Data derivation language
Dynamic data language
Detailed data language
Hide
Correct Answer
Explanation: The full form of DDL is Data definition language.
15. 
Which SQL constraint do we use to set some value to a field whose value has not been
added explicitly?
UNIQUE
NOT NULL
DEFAULT
CHECK
Hide
Wrong Answer
Explanation: The DEFAULT constraint is used to set a default value for a column which
comes into use when a value for a field in that column is not set.
16. 
What are rows of a relation known as?
Degree
Entity
Tuple
None
Hide
Wrong Answer
Explanation: The rows of a relation are known as tuples.
17. 
During transaction before commit which of the following statements is done
automatically in case of shutdown?
Rollback
Commit
View
Flashback
Hide
Wrong Answer
Explanation: In case of a shutdown, before committing, Rollback is done.
18. 
Which of the following allows you to uniquely identify a tuple?
Schema
Attribute
Super key
Domain
Hide
Wrong Answer
Explanation: Super Key is used to uniquely identify a tuple in a relation.
19. 
How many operations are considered to be the most basic SQL operations?
4
3
2
1
Hide
Wrong Answer
Explanation: The 4 basic SQL operations are: Create, Read, Update and Delete(CRUD).
20. 
Which of the following is not a SQL command?
DELETE
ORDER BY
SELECT
WHERE
Hide
Wrong Answer
Explanation: DELETE is not a SQL command.
21. 
What does the following code snippet do?
SELECT TOP 5 * FROM students;
Select the top 5 entries for all the columns in the students' table.
Select all the entries from the students' table other than the top 5 entries
Selects all entries from the student table except 5 random rows
None of the above
Hide
Wrong Answer
Explanation: The above code snippet basically selects all the top 5 rows from the
students' table.
22. 
Which of the following matches the definition given below: It is an artificial key that
aims to uniquely identify each record.
Primary Key
Foreign Key
Surrogate Key
Composite Key
Hide
Wrong Answer
Explanation: Surrogate Key is an artificial key that aims to uniquely identify each
record.
23. 
Which of the following commands are used to put a restriction on the number of rows
returned from a query?
LIMIT
LIKE
WHERE
GROUP BY
Hide
Wrong Answer
Explanation: LIMIT is used to put a restriction on how many rows are returned from a
query.
24. 
Which of the following are valid logical operators in SQL?
SOME
ALL
AND
All of the above
Hide
Wrong Answer
Explanation: All of the above expressions are valid logical operators in SQL.
25. 
Which of the following SQL functions compares the similarities of 2 strings and returns
the result as a 4 character code?
SOUNDEX
DIFFERENCE
CONCAT
None of the above
Hide
Wrong Answer
Explanation: SOUNDEX compares 2 strings and returns their similarity as a 4 character
code.
26. 
To select some particular columns, which of the following commands is used?
PROJECTION
SELECTION
JOIN
UNION
Hide
Wrong Answer
Explanation: To select some particular commands, PROJECTION is used.
27. 
Primary key can be?
NULL
NOT NULL
Both NULL and NOT NULL
Depends on situation
Hide
Wrong Answer
Explanation: Primary key must always be NOT NULL.
28. 
Select the valid SQL type.
NUMERIC
CHARACTER
FLOAT
All of the above
Hide
Wrong Answer
Explanation: All of the above options are valid SQL types.
29. 
Which of the following functions do we use to get a specified day of the month for a
given date?
DAY
DATEPART
GETDATE
CURRENT_TIMESTAMP
Hide
Wrong Answer
Explanation: DAY is used to get the specified day of the month for a given date.
30. 
Which of the following operators is used to compare a value to a list of literal values
that have been specified?
ANY
BETWEEN
IN
ALL
Hide
Wrong Answer
Explanation: The BETWEEN operator is used to compare a value to a list of literal
values that have been specified.
31. 
What is a table joined with itself called?
Join
Self-join
Outer join
None of the above
Hide
Wrong Answer
Explanation: Table joined with itself is called a self join.
32. 
NATURAL JOIN can also be termed as -
Combination of Union and cartesian product
Combination of Selection and cartesian product
Combination of Projection and cartesian product
None of the above
Hide
Wrong Answer
Explanation: NATURAL JOIN can also be termed as a combination of Projection and
cartesian product.
33. 
Which of the following commands is used to delete a trigger in SQL?
DROP
DELETE
ALTER
None of the above
Hide
Wrong Answer
Explanation: The DROP command is used to delete a trigger in SQL.
34. 
How can we view all the triggers currently in the database?
SHOW
VIEW
READ
None of the above
Hide
Wrong Answer
Explanation: The SHOW command will display all the triggers that are currently
present in the table.
35. 
Which of the following is known as the minimal super key?
Primary key
Foreign key
Candidate key
None of the above
Hide
Wrong Answer
Explanation: The Candidate Key is also known as the minimal super key.
36. 
Select the correct foreign key constraint?
Referential integrity
Entity integrity
Domain integrity
None of the above
Hide
Wrong Answer
Explanation: The most important foreign key constraint is Referential Integrity.
37. 
What is NOLOCK in SQL equivalent to?
WRITE UNCOMMITTED
READ COMMITTED
WRITE COMMITTED
READ UNCOMMITTED
Hide
Wrong Answer
Explanation: The NOLOCK in SQL is equivalent to READ UNCOMMITTED.
38. 
Which of the following can replace the below query?
SELECT Name, ID
FROM Student, Courses
WHERE Student_ID = Courses_ID;
Select Name,ID from Courses,Student where Student_ID = ID;
Select Name, ID from Student natural join Courses;
Select Name, ID from Student;
Select ID from Student join Courses;
Hide
Wrong Answer
Explanation: The correct replacement of the above query is shown in option B.
39. 
What will be the output of the following code snippet?
SELECT ROUND (TRUNCATE (MOD (2500, 20), -1), 2) FROM dual;
Error
00
0
1
Hide
Wrong Answer
Explanation: The MOD(2500, 20) expression will return 0, after which the rest of the
functions will just be applied on the value 0.
40. 
How can the user change “Scaler” into “Interviewbit” in the “Name” column in the
Users table?
UPDATE User SET Name = 'Scaler' INTO Name = 'Interviewbit'
MODIFY Users SET Name = 'Interviewbit' WHERE Name = 'Scaler'
MODIFY Users SET Name = 'Scaler' INTO Name = 'Interviewbit'
UPDATE Users SET Name = 'Interviewbit' WHERE Name = 'Scaler'
Hide
Wrong Answer
Explanation: The UPDATE command and WHERE clause are used together to change
the name as asked in the question.
41. 
What is the name of the query that is placed within a WHERE or HAVING clause of
another query?
Multi query
Subquery
Super query
Master query
Hide
Wrong Answer
Explanation: It is called subquery.
42. 
Which is the AS clause used for?
Rename
Selection
Join
Projection
Hide
Wrong Answer
Explanation: The AS is used for the renaming functionality.
43. 
Which of the following are valid SQL constraints?
NOT NULL
CHECK
UNIQUE
All of the above
Hide
Correct Answer
Explanation: All of the above are valid SQL constraints.
44. 
Which of the following is also known as a concatenated key?
Primary Key
Foreign Key
Surrogate Key
Composite Key
Hide
Wrong Answer
Explanation: Composite key is also known as a concatenated key since it is composed
of one or more columns.
45. 
The program which performs some common action on database data and is also
stored there is called?
Trigger
Stored Procedure
Stored Function
None of the above
Hide
Wrong Answer
Explanation: SQL procedures are stored in SQL codes, which can be saved for reuse
again and again.
46. 
How can SQL injections occur?
Data is used to dynamically construct an SQL Query.
Unintended data from an untrusted source enters the application.
Both A and B.
None of the above.
Hide
Wrong Answer
Explanation: SQL injections can occur in the 2 ways described in options A and B.
47. 
Which of the following constraints can be defined only at the column level?
UNIQUE
NOT NULL
CHECK
PRIMARY KEY
Hide
Wrong Answer
Explanation: NOT NULL constraint can be defined only at the column level.
48. 
Group of operations that form a single logical unit of work called?
Network
Unit
Transaction
None of the above
Hide
Wrong Answer
Explanation: A logical group of statements that is written to perform a single unit of
work is called a transaction.
49. 
Identify the concurrency-based protocol?
Lock based protocol
Two-phase locking protocol
Timestamp ordering protocol
All
Hide
Wrong Answer
Explanation: All of the above options are concurrency-based protocols.
50. 
Which of the following is not a valid SQL type?
NUMERIC
DECIMAL
CHARACTER
None of the above
Hide
Wrong Answer
Explanation: DECIMAL is not a valid SQL type.
51. 
What is the full form of SQL?
Structured Query Language
Sample Query Language
Structured Query List
None of the above.
Hide
Wrong Answer
Explanation: SQL is the abbreviation for Structured Query Language.
52. 
Which of the following is not a DDL command?
REVOKE
GRANT
UPDATE
RENAME
Hide
Wrong Answer
Explanation: RENAME is not a DDL command.
53. 
Which of the following are TCL commands?
ROLLBACK
SAVEPOINT
Both A and B
None of the above
Hide
Wrong Answer
Explanation: Both A and B are TCL commands.
54. 
SQL views are also known as?
Schema
Virtual Table
Instance
None of the above
Hide
Wrong Answer
Explanation: SQL Views are also known as Virtual Table.
55. 
Which of the following is not a valid aggregate function?
count()
Sum()
Avg()
None of the above
Hide
Wrong Answer
Explanation: All of the above options are valid aggregate functions in SQL.

You might also like