Basic SQL Queries MCQ Quiz in मल्याळम - Objective Question with Answer for Basic SQL Queries - സൗജന്യ PDF ഡൗൺലോഡ് ചെയ്യുക
Last updated on Mar 11, 2025
Latest Basic SQL Queries MCQ Objective Questions
Top Basic SQL Queries MCQ Objective Questions
Basic SQL Queries Question 1:
Which of the following statement is a part of Data Manipulative Language in Structured Query Language?
Answer (Detailed Solution Below)
Basic SQL Queries Question 1 Detailed Solution
DDL – Data Definition Language
- CREATE
- DROP
- ALTER
- TRUNCATE
- COMMENT
- RENAME
DQL – Data Query Language
- SELECT
DML – Data Manipulation Language
- INSERT
- UPDATE
- DELETE
DCL – Data Control Language
- GRANT
- REVOKE
TCL – Transaction Control Language
- COMMIT
- ROLLBACK
- SAVEPOINT
- SET TRANSACTION
Hence the correct answer is Delete.
Basic SQL Queries Question 2:
Comprehension:
Comprehension: Consider the following table structures related to a university for given questions.
EMPLOYEE
NAME |
VARCHAR (30) |
NOT NULL, |
EID |
VARCHAR (10) |
NOT NULL, |
DEPTNO |
INT (5) |
NOT NULL, |
HODEID |
VARCHAR (10), |
|
SALARY |
INT (10), |
|
PRIMARY KEY (EID),
FOREIGN KEY (HODEID) REFRENCES EMPLOYEE (EID),
FOREIGN KEY (DEPTNO) REFRENCES DEPARTMENT (DID);
DEPARTMENT
DID |
INT (5) |
NOT NULL, |
DNAME |
VARCHAR (30) |
NOT NULL, |
HODID |
VARCHAR (10) |
NOT NULL, |
HODNAME |
VARCHAR (30), |
|
PRIMARY KEY (DID),
UNIQUE (DNAME),
FOREIGN KEY (HODID) REFERENCES EMPLOYEE (EID),
PROJECT WORE:
EMPID |
VARCHAR (10) |
NOT NULL, |
PROJNO |
INT (5) |
NOT NULL, |
PROJECTLOC |
VARCHAR (30) |
NOT NULL, |
PRIMARY KEY (EMPID, PROJNQ),
FOREIGN KEY (EMPID) REFERENCES EMPLOYEE (EID),
In reference to the above given table structures, which of the following query/queries will drop the ‘SALARY’ column from 'EMPLOYEE' table ?
(A) ALTER TABLE EMPLOYEE DROP SALARY CASCADE;
(B) ALTER TABLE EMPLOYEE DROP SALARY RESTRICT;
(C) ALTER EMPLOYEE DROP SALARY:
Choose the correct answer from the options given below:
Answer (Detailed Solution Below)
Basic SQL Queries Question 2 Detailed Solution
The correct answer is option 1.
Key Points
Alter table Syntax:
ALTER TABLE table-Name
DROP [ COLUMN ] column-name [ CASCADE | RESTRICT ]
- The keyword COLUMN, CASCADE, RESTRICT are optional. The default is CASCADE. If you use the RESTRICT option, the column drop will be rejected if it would invalidate a dependent schema object. If CASCADE is defined, the column drop should also remove any other schema objects that have become invalid.
- Since the salary field is not present in any other table, CASCADE | RESTRICT has no impact.
-
(C) ALTER EMPLOYEE DROP SALARY is incorrect syntax.
∴ Hence the correct answer is (A) and (B) only.
Basic SQL Queries Question 3:
The SQL ALTER TABLE statement is used to:
Answer (Detailed Solution Below)
Basic SQL Queries Question 3 Detailed Solution
Concept:
The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
The ALTER TABLE statement is also used to add and drop various constraints on an existing table.
ADD Column
To add a column in a table, use the following syntax:
ALTER TABLE table_name ADD column_name datatype;
DROP COLUMN
To delete a column in a table, use the following syntax (notice that some database systems don't allow deleting a column):
ALTER TABLE table_name DROP COLUMN column_name;
Basic SQL Queries Question 4:
Which of the following command is incorrectly matched?
Answer (Detailed Solution Below)
Basic SQL Queries Question 4 Detailed Solution
The correct answer is option 3.
Concept:
Option 1: CREATE USER to create a new user name and password.
True, The CREATE USER statement creates and configures a database user, which is an account that allows you to log in to the database, as well as the means by which Oracle Database allows the user access.
Option 2: GRANT to provide system-level database access permission to users.
True, The SQL Grant command is being used to grant user privileges to database objects. Users can also use this command to grant permissions to other users.
Option 3: PERMIT to provide object-level database access permission to users
False, Use the PERMIT command to keep track of the users and groups who have permission to access a specific resource and it is used to provide system-level database access permission to users like the user IDs and group names authorized to access the resource, as well as the level of access granted to each, are included in the standard access list.
Option 4:REVOKE to cancel the permission to access the database.
True, If any user privileges on database objects have been granted, the Revoke command will remove them. It performs activities in the opposite direction as the Grant command. When a user's privileges are withdrawn, the privileges that user U gave to all other users are also revoked.
Hence the correct answer is PERMIT to provide object-level database access permission to users.
Basic SQL Queries Question 5:
What is the operator precedence in SQL queries?
i) Assignment
ii) Bitwise Not
iii) Multiply
iv) BETWEEN
v) Comparison operators
Answer (Detailed Solution Below)
Basic SQL Queries Question 5 Detailed Solution
The correct answer is option 1.
Concept:
The grouping of terms in an expression is determined by operator precedence. This has an impact on the way an expression is assessed. Certain operators are prioritized above others.
Explanation:
The order is as follows:
Level | Operators |
1 | ~ (Bitwise NOT) |
2 | * (Multiply), / (Division), % (Modulo) |
3 | + (Positive), - (Negative), + (Add), (+ Concatenate), - (Subtract), & (Bitwise AND), ^ (Bitwise Exclusive OR), | (Bitwise OR) |
4 | =, >, <, >=, <=, <>, !=, !>, !< (Comparison operators) |
5 | NOT |
6 | AND |
7 | ALL, ANY, BETWEEN, IN, LIKE, OR, SOME |
8 | = (Assignment) |
Hence the correct answer is ii,iii,v,iv,i.
Basic SQL Queries Question 6:
What is the operator precedence in SQL queries?
i) Assignment
ii) Bitwise Not
iii) Multiply
iv) BETWEEN
v) Comparison operators
Answer (Detailed Solution Below)
Basic SQL Queries Question 6 Detailed Solution
The correct answer is option 1.
Concept:
The grouping of terms in an expression is determined by operator precedence. This has an impact on the way an expression is assessed. Certain operators are prioritized above others.
Explanation:
The order is as follows:
Level | Operators |
1 | ~ (Bitwise NOT) |
2 | * (Multiply), / (Division), % (Modulo) |
3 | + (Positive), - (Negative), + (Add), (+ Concatenate), - (Subtract), & (Bitwise AND), ^ (Bitwise Exclusive OR), | (Bitwise OR) |
4 | =, >, <, >=, <=, <>, !=, !>, !< (Comparison operators) |
5 | NOT |
6 | AND |
7 | ALL, ANY, BETWEEN, IN, LIKE, OR, SOME |
8 | = (Assignment) |
Hence the correct answer is ii,iii,v,iv,i.
Basic SQL Queries Question 7:
Which is not aggregate function in SQL?
Answer (Detailed Solution Below)
Basic SQL Queries Question 7 Detailed Solution
Aggregate functions return a single result row based on groups of rows, rather than on single rows. Aggregate functions can appear in select lists and in ORDER BY and HAVING clauses.
Function |
Description |
COUNT |
COUNT returns the number of rows returned by the query |
AVG |
AVG returns average value of expression |
MIN |
MIN returns minimum value of expression |
SUM |
SUM returns the sum of values of expression |
Note:
AVG is aggregate function but not AVERAGEBasic SQL Queries Question 8:
Truncating tables shall ________.
Answer (Detailed Solution Below)
Basic SQL Queries Question 8 Detailed Solution
The correct answer is option 1.
Concept:
TRUNCATE TABLE removes all rows from a table, but the table structure and its columns, constraints, indexes, and so on remain. To remove the table definition in addition to its data, use the DROP TABLE statement.
SQL Truncate:
The TRUNCATE TABLE command deletes the data inside a table, but not the table itself.
Syntax:
TRUNCATE TABLE table_name;
SQL Drop:
The DROP TABLE command deletes a table in the database.
Syntax:
DROP TABLE table_name;
So truncating tables shall empty a table completely but drop table deletes a table in the database.
Hence the correct answer is empty a table completely.
Basic SQL Queries Question 9:
Consider the following relation schema R along with the tuples.
Employee(name, salary) = {
What is the output of following SQL query?
SELECT name, MAX (salary) FROM Employee WHERE salary < (SELECT MAX (salary) FROM Employee);Answer (Detailed Solution Below)
Basic SQL Queries Question 9 Detailed Solution
Employee relation in table form:
name |
salary |
e1 |
10000 |
e2 |
5000 |
e3 |
2500 |
e4 |
7500 |
e5 |
8900 |
e6 |
9800 |
Inner query: (SELECT MAX(salary) FROM Employee;
It selects the maximum salary from above table i.e. 10000
Now for outer query, first we have to find all the employee name having salary less than 10000.
Then select the maximum from them i.e. indirectly whole query is selecting the employee having second highest salary.
It will result in:
Name |
Salary |
e6 |
9800 |
Basic SQL Queries Question 10:
A clause in SQL allows you to rename a table or a column temporarily by giving another name known as alias. The renaming is a temporary change and the actual table name does not change in the database. Which of the following clauses, allows such option?
Answer (Detailed Solution Below)
Basic SQL Queries Question 10 Detailed Solution
The correct answer is option 3.
Concept:
In SQL, we can temporarily rename a table or a column by giving it another name known as Alias. Table aliases are used to rename a table in a specific SQL statement. The renaming is only a temporary change, and the actual table name in the database remains unchanged.
Syntax: The following is the basic syntax for a table alias.
SELECT column1, column2....
FROM table_name AS alias_name
WHERE [condition];
Syntax: The following is the basic syntax for a column alias.