SQL Tutorial
SQL Database
SQL Table
SQL Select
SQL Order By
SQL Insert
SQL Update
SQL Delete
Difference
SQL Injection
SQL String Functions
Miscl
- SQL Formatter
- SQL group by
- SQL add/drop/update column operation
- SQL CAST Function
- SQL Comments
- SQL CONCAT Function
- CTE (Common Table Expression)SQL
- How to use distinct in SQL?
- Joining Three or More Tables in SQL
- What is Web SQL?
- How to create functions in SQL?
- How to run SQL Script?
- How to Delete Duplicate Rows in SQL?
- Nth Highest salary
- 12 Codd's Rules
- SQL EXCEPT
- Types of SQL JOIN
- Change datatype of column in SQL
- SQL Auto Increment
- SQL Like
- Commit and Rollback in SQL
- SQL Concatenate
- SQL get month from the date
- Savepoint in SQL
- SQL ORDER BY DATE
- TIME Datatype in SQL
- SQL BETWEEN
- CRUD Operations in SQL
- SQL INDEX
- Scalar Functions in SQL
- SET Operators in SQL
- Types of SQL Commands
- TCL Commands in SQL
- SQL Subquery
- SQL View
- Constraints in SQL
- Pattern Matching in SQL
- SQL Date Functions
- DDL Commands in SQL
- DML Commands in SQL
- SQL CASE
- SQL Inner Join
- SQL IN Operator
- Check Constraint in SQL
- SQL CLAUSES
- SQL LOGICAL OPERATORS
- Delete Column from Table
- Add Column in the Table
- Delete one row in SQL
- Change the Column Value
- How to Add Foreign Key in SQL
- Add a Primary Key
- Insert One or More rows
- How to Use LIKE in SQL
- Cursor in SQL
- Difference Between DROP and Truncate
- SQL Comparison Operators
- SQL COUNT WHERE
- SQL SELECT MIN
- SQL Stored Procedure
- SQL SELECT AVG
- SQL SELECT MAX
- SQL ADD COLUMN
- How to use Auto-Increment in SQL
- SQL Languages
- SQL Arithmetic Operators
- How to Use GROUP BY in SQL
- How to Use ORDER BY in SQL
- Trigger in SQL
- What is Race Condition
- SQL COUNT DISTINCT
PL/SQL Tutorial
Sql Interview Question
SQl Quiz
SQL MCQ (Multiple Choice Questions)
Here we are going to see a list of important SQL questions in MCQ style with an explanation of the answer for competitive exams and interviews. These frequently asked SQL questions are given with the correct choice of answer among multiple options. You can select your choice and check it instantly to see the answer with an explanation.
1) What is the full form of SQL?
- Structured Query List
- Structure Query Language
- Sample Query Language
- None of these.
Show Answer Workspace
2) Which of the following is not a valid SQL type?
- FLOAT
- NUMERIC
- DECIMAL
- CHARACTER
Show Answer Workspace
3) Which of the following is not a DDL command?
- TRUNCATE
- ALTER
- CREATE
- UPDATE
Show Answer Workspace
4) Which of the following are TCL commands?
- COMMIT and ROLLBACK
- UPDATE and TRUNCATE
- SELECT and INSERT
- GRANT and REVOKE
Show Answer Workspace
5) Which statement is used to delete all rows in a table without having the action logged?
- DELETE
- REMOVE
- DROP
- TRUNCATE
Show Answer Workspace
6) SQL Views are also known as
- Simple tables
- Virtual tables
- Complex tables
- Actual Tables
Show Answer Workspace
7) How many Primary keys can have in a table?
- Only 1
- Only 2
- Depends on no of Columns
- Depends on DBA
Show Answer Workspace
8) Which datatype can store unstructured data in a column?
- CHAR
- RAW
- NUMERIC
- VARCHAR
Show Answer Workspace
9) Which of the following is not Constraint in SQL?
- Primary Key
- Not Null
- Check
- Union
Show Answer Workspace
10) Which of the following is not a valid aggregate function?
- COUNT
- COMPUTE
- SUM
- MAX
Show Answer Workspace
11) Which data manipulation command is used to combines the records from one or more tables?
- SELECT
- PROJECT
- JOIN
- PRODUCT
Show Answer Workspace
12) Which operator is used to compare a value to a specified list of values?
- ANY
- BETWEEN
- ALL
- IN
Show Answer Workspace
13) What operator tests column for absence of data
- NOT Operator
- Exists Operator
- IS NULL Operator
- None of the above
Show Answer Workspace
14) In which of the following cases a DML statement is not executed?
- When existing rows are modified.
- When a table is deleted.
- When some rows are deleted.
- All of the above
Show Answer Workspace
15) If we have not specified ASC or DESC after a SQL ORDER BY clause, the following is used by default
- DESC
- ASC
- There is no default value
- None of the mentioned
Show Answer Workspace
16) Which of the following statement is true?
- TRUNCATE free the table space while DELETE does not.
- Both TRUNCATE and DELETE statements free the table's space.
- Both TRUNCATE and DELETE statement does not free the table's space.
- DELETE free the table space while TRUNCATE does not.
Show Answer Workspace
17) What is returned by INSTR ('JAVAT POINT', 'P')?
- 6
- 7
- POINT
- JAVAT
Show Answer Workspace
18) A command that lets you change one or more field in a table is:
- INSERT
- MODIFY
- LOOK-UP
- All of the above
Show Answer Workspace
19) Which of the following is also called an INNER JOIN?
- SELF JOIN
- EQUI JOIN
- NON-EQUI JOIN
- None of the above
Show Answer Workspace
20) Which of the following is true about the HAVING clause?
- Similar to the WHERE clause but is used for columns rather than groups.
- Similar to WHERE clause but is used for rows rather than columns.
- Similar to WHERE clause but is used for groups rather than rows.
- Acts exactly like a WHERE clause.
Show Answer Workspace
21) _______ clause creates temporary relation for the query on which it is defined.
- WITH
- FROM
- WHERE
- SELECT
Show Answer Workspace
22) The SQL statement:
- SELECT ROUND (65.726, -1) FROM DUAL;
Prints:
- is illegal
- garbage
- 726
- 70
Show Answer Workspace
23) Which of the following is true about the SQL AS clause?
- The AS clause in SQL is used to change the column name in the output or assign a name to a derived column.
- The SQL AS clause can only be used with the JOIN clause.
- The AS clause in SQL is used to defines a search condition.
- All of the mentioned
Show Answer Workspace
24) _________ command makes the updates performed by the transaction permanent in the database?
- ROLLBACK
- COMMIT
- TRUNCATE
- DELETE
Show Answer Workspace
25) How can you change "Thomas" into "Michel" in the "LastName" column in the Users table?
- UPDATE User SET LastName = 'Thomas' INTO LastName = 'Michel'
- MODIFY Users SET LastName = 'Michel' WHERE LastName = 'Thomas'
- MODIFY Users SET LastName = 'Thomas' INTO LastName = 'Michel'
- UPDATE Users SET LastName = 'Michel' WHERE LastName = 'Thomas'
Show Answer Workspace
26) Which command is used to change the definition of a table in SQL?
- CREATE
- UPDATE
- ALTER
- SELECT
Show Answer Workspace
27) Which type of JOIN is used to returns rows that do not have matching values?
- Natural JOIN
- Outer JOIN
- EQUI JOIN
- All of the above
Show Answer Workspace
28) A CASE SQL statement is ________?
- A way to establish a loop in SQL.
- A way to establish an IF-THEN-ELSE in SQL
- A way to establish a data definition in SQL
- All of the above.
Show Answer Workspace
29) Which statement is true regarding routines and triggers?
- Both run automatically.
- Both are stored in the database.
- Both consist of procedural code.
- Both have to be called to operate.
Show Answer Workspace
30) Which statement is true regarding procedures?
- They include procedural and SQL statements.
- They work similarly to the functions.
- It does not need unique names.
- It cannot be created with SQL statements.
Show Answer Workspace
31) Which of the following is the basic approaches for joining tables?
- Union JOIN
- Natural JOIN
- Subqueries
- All of the above
Show Answer Workspace
32) Why we need to create an index if the primary key is already present in a table?
- Index improves the speed of data retrieval operations on a table.
- Indexes are special lookup tables that will be used by the database search engine.
- Indexes are synonyms of a column in a table.
- All of the above
Show Answer Workspace
33) Group of operations that form a single logical unit of work is known as
- View
- Network
- Unit
- Transaction
Show Answer Workspace
34) Shared locks are applied while performing
- Read operations
- Write operations
- A & B both
- None of the above
Show Answer Workspace
35) Sequence can generate
- Numeric value
- Alphanumeric value
- A & B both
- None of the above
Show Answer Workspace
36) A sequence in SQL can generate a maximum number:
- 39 digits
- 38 digits
- 40 digits
- 37 digits
Show Answer Workspace
37) Which of the following is the correct order of a SQL statement?
- SELECT, GROUP BY, WHERE, HAVING
- SELECT, WHERE, GROUP BY, HAVING
- SELECT, HAVING, WHERE, GROUP BY
- SELECT, WHERE, HAVING, GROUP BY
Show Answer Workspace
38) What is the difference between a PRIMARY KEY and a UNIQUE KEY?
- Primary key can store null value, whereas a unique key cannot store null value.
- We can have only one primary key in a table while we can have multiple unique keys
- Primary key cannot be a date variable whereas unique key can be
- None of these
Show Answer Workspace
39) Which of the following are the synonyms for Column and ROW of a table?
- Row = [Tuple, Record]
- Column = [Field, Attribute]
- Row = [Tuple, Attribute]
- Columns = [Field, Record]
- 1 and 2
- 3 and 4
- Only 1
- Only 2
Show Answer Workspace
40) Which operator is used to compare the NULL values in SQL?
- Equal
- IN
- IS
- None of Above
Show Answer Workspace
41) Which of the following statement is correct regarding the difference between TRUNCATE, DELETE and DROP command?
I. DELETE operation can be rolled back but TRUNCATE and DROP operations cannot be rolled back.
II. TRUNCATE and DROP operations can be rolled back but DELETE operations cannot be rolled back.
III. DELETE is an example of DML, but TRUNCATE and DROP are examples of DDL.
IV. All are an example of DDL.
- I and III
- II and III
- II and IV
- II and IV
Show Answer Workspace
42) Which of the following options are correct regarding these three keys (Primary Key, Super Key, and Candidate Key) in a database?
I. Minimal super key is a candidate key
II. Only one candidate key can be a primary key
III. All super keys can be a candidate key
IV. We cannot find a primary key from the candidate key
- I and II
- II and III
- I and III
- II and IV
Show Answer Workspace
43) When the wildcard in a WHERE clause is useful?
- When an exact match is required in a SELECT statement.
- When an exact match is not possible in a SELECT statement.
- When an exact match is required in a CREATE statement.
- When an exact match is not possible in a CREATE statement.
Show Answer Workspace
44) ______ is NOT a type of constraint in SQL language?
- FOREIGN KEY
- PRIMARY KEY
- UNIQUE
- ALTERNATE KEY
Show Answer Workspace
45) Find the cities name with the condition and temperature from table 'whether' where condition = sunny or cloudy but temperature >= 60.
- SELECT city, temperature, condition FROM weather WHERE condition = 'cloudy' AND condition = 'sunny' OR temperature >= 60
- SELECT city, temperature, condition FROM weather WHERE condition = 'cloudy' OR condition = 'sunny' OR temperature >= 60
- SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' OR condition = 'cloudy' AND temperature >= 60
- SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' AND condition = 'cloudy' AND temperature >= 60
Show Answer Workspace
46) Which of the following statement is correct to display all the cities with the condition, temperature, and humidity whose humidity is in the range of 60 to 75 from the 'whether' table?
- SELECT * FROM weather WHERE humidity IN (60 to 75)
- SELECT * FROM weather WHERE humidity BETWEEN 60 AND 75
- SELECT * FROM weather WHERE humidity NOT IN (60 AND 75)
- SELECT * FROM weather WHERE humidity NOT BETWEEN 60 AND 75
Show Answer Workspace
47) ________ is a program that performs some common action on database data and also stored in the database.
- Stored Procedure
- Trigger
- Stored Function
- None of the above
Show Answer Workspace
48) Which statement is used to get all data from the student table whose name starts with p?
- SELECT * FROM student WHERE name LIKE '%p%';
- SELECT * FROM student WHERE name LIKE 'p%';
- SELECT * FROM student WHERE name LIKE '_p%';
- SELECT * FROM student WHERE name LIKE '%p';
Show Answer Workspace
49) What is the advantage of the clustered index?
- It is fast to update the records.
- It does not need extra work for SQL queries.
- It minimizes the page transfer and maximizes the cache hits.
- None of the above is correct.
Show Answer Workspace
50) Evaluate the SQL statement:
- SELECT a.emp_name, a.sal, a.dept_id, b.maxsal FROM employees a,
- (SELECT dept_id, MAX(sal) maxsal FROM employees GROUP BY dept_id) b
- WHERE a.dept_id = b.dept_id AND a.sal < b.maxsal;
Which of the following statement is correct?
- The statement gives an error at line 1.
- The statement gives an error at line 6.
- The statement produces the employee name, salary, department ID, and maximum salary earned in the employee department for all departments that pay less salary than the maximum salary paid in the company.
- The statement produces the employee name, salary, department ID, and maximum salary earned in the employee department for all employees who earn less than the maximum salary in their department.
Show Answer Workspace
51) Which of the following are the DATETIME data types that can be used in column definitions?
- TIMESTAMP
- INTERVAL MONTH TO DAY
- INTERVAL YEAR TO MONTH
- TIMESTAMP WITH DATABASE TIMEZONE
Show Answer Workspace
52) Which data dictionary table can be used to show the object privileges granted to the user on specific columns?
- USER_TAB_PRIVS_MADE
- USER_COL_PRIVS_MADE
- USER_TAB_PRIVS
- USER_COL_PRIVS
Show Answer Workspace
53) Evaluate the SQL statement:
- SELECT ROUND (TRUNCATE (MOD (1600, 10), -1), 2) FROM dual;
What will be displayed?
- 0
- 1
- 00
- An error statement
Show Answer Workspace
54) What is the need for our query to execute successfully on an existing view?
- The specified table must contain data.
- We must have a SELECT privilege on the view.
- We should have a SELECT privilege only on the specified table.
- The specified table must be in the same database or schema.
Show Answer Workspace
55) Which of the following operator can be used with a multiple-row subquery?
- =
- BETWEEN
- NOT IN
- <>
Show Answer Workspace
56) _______ is a constraint that can be defined only at the column level?
- UNIQUE
- NOT NULL
- CHECK
- PRIMARY KEY
Show Answer Workspace