Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Tests  >  Test: SQL - 3 - Computer Science Engineering (CSE) MCQ

Test: SQL - 3 - Computer Science Engineering (CSE) MCQ


Test Description

10 Questions MCQ Test - Test: SQL - 3

Test: SQL - 3 for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Test: SQL - 3 questions and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus.The Test: SQL - 3 MCQs are made for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: SQL - 3 below.
Solutions of Test: SQL - 3 questions in English are available as part of our course for Computer Science Engineering (CSE) & Test: SQL - 3 solutions in Hindi for Computer Science Engineering (CSE) course. Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free. Attempt Test: SQL - 3 | 10 questions in 30 minutes | Mock test for Computer Science Engineering (CSE) preparation | Free important questions MCQ to study for Computer Science Engineering (CSE) Exam | Download free PDF with solutions
Test: SQL - 3 - Question 1

Which SQL aggregate function is used to retrieve minimum value?

Detailed Solution for Test: SQL - 3 - Question 1

Aggregate functions are functions that take a collection (a set or multiset) of values as input and return a single value. SQL offers five built-in aggregate functions:

  • Average: avg
  • Minimum: min
  • Maximum: max
  • Total: sum
  • Count: count
Test: SQL - 3 - Question 2

Employee salary should not be greater than Rs. 12,000. This is

Detailed Solution for Test: SQL - 3 - Question 2

Key Points

  • An Integrity constraint is a rule that ensures the accuracy and consistency of data within a relational database.
  • In this context, the constraint ensures that an employee's salary should not exceed Rs. 12,000.
  • Integrity constraints can be applied to ensure that the data entered into a database adheres to certain rules or conditions.

Additional Information

  • Referential constraint: This type of constraint ensures that a foreign key value always points to an existing row in another table, maintaining referential integrity between tables.
  • Over-defined constraint: This term is not commonly used in database terminology. It might imply an excessive or redundant constraint, but it is not a standard term.
  • Feasible constraint: This term suggests a constraint that is practical and possible to implement but does not specifically refer to database constraints.
1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: SQL - 3 - Question 3

_________ is not a DDL command.

Detailed Solution for Test: SQL - 3 - Question 3

Key Points

  • DDL stands for Data Definition Language.
  • DDL commands are used to define and modify the structure of a database, such as creating or removing tables and specifying the data types of columns.
  • Update is a DML (Data Manipulation Language) command.
  • DML commands are used to manipulate the data within a database, such as inserting, updating, and deleting records.
  • The other options (Drop, Alter, Create) are all DDL commands.

Breakdown of all the options:

  • Drop: This command removes a database object, such as a table.
  • Alter: This command modifies the structure of an existing database object.
  • Update: This command modifies the data within a table. (Not a DDL command it is DML command)
  • Create: This command creates a new database object, such as a table.
Test: SQL - 3 - Question 4

In SQL, like condition allows you to use wild card characters to perform matching. Which of the following is a valid wild card character?

Detailed Solution for Test: SQL - 3 - Question 4

Key Points
The commonly used wildcard characters in SQL LIKE:

  • %: Matches zero, one, or more characters.
  • _: Matches a single character (any letter, number, or symbol).

Examples:

  • SELECT * FROM customers WHERE name LIKE '%en%'; - This query will find all customer names that contain the letters "en" anywhere in the name (e.g., "John", "Steven", "Weekend").
  • SELECT * FROM products WHERE code LIKE 'PR%'; - This query will find all product codes that start with "PR" followed by any characters (e.g., "PR123", "PR-ABC").
  • SELECT * FROM users WHERE username LIKE 'user_'; - This query will find all usernames that start with "user_" followed by a single character (e.g., "user_a", "user_1").
Test: SQL - 3 - Question 5

_______ symbol is used to see every column of a table.

Detailed Solution for Test: SQL - 3 - Question 5

The * symbol is used to see every column of a table.
 For Example, Let us consider a table Table1

If you want to fetch only some specific columns from the table, then we can use this query,
Select ID,NAME,AGE from Table1; // Syntax is Select (column_name1, coloumn_name2.....coloum_name) from table_name;

If you want to fetch all the fields of the Table1 table, then you should use the following query , 
Select * from Table1;    // Syntax is Select * from table_name;

Therefore Option 3 is correct

Test: SQL - 3 - Question 6

Consider the schema
Sailors(sid, sname, rating, age) with the following data

For the query
SELECT S.rating, AVG(S.age) AS avgage FROM Sailors S
Where S.age >= 18
GROUP BY S.rating
HAVING 1 < (SELECT COUNT(*) FROM Sailors S2 where S.rating = S2.rating)
The number of rows returned is

Detailed Solution for Test: SQL - 3 - Question 6

Without "having" clause query calculates the average age (where age >= 18) and groups by ratings so table returned is:

After applying "having" clause table returned is:

Test: SQL - 3 - Question 7

Which of the following statements are TRUE about an SQL query?
P: An SQL query can contain a HAVING clause even if it does not have a GROUP BY clause
Q: An SQL query can contain a HAVING clause only if it has a GROUP BY clause
R: All attributes used in the GROUP BY clause must appear in the SELECT clause
S: Not all attributes used in the GROUP BY clause need to appear in the SELECT clause

Detailed Solution for Test: SQL - 3 - Question 7

GROUP BY clause:

  • The GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each country".
  • The GROUP BY statement is often used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns.

Syntax:
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)

Example:
SELECT COMPANY, COUNT(*)  
FROM PRODUCT_MAST   
GROUP BY COMPANY 

Therefore all attributes used in the GROUP BY clause must appear in the SELECT clause 

HAVING clause:
HAVING clause is used to specify a search condition for a group or an aggregate.
Having is used in a GROUP BY clause.
If you are not using GROUP BY clause then you can use HAVING function like a WHERE clause.

Syntax:
SELECT column1, column2   
FROM table_name  
WHERE conditions   
GROUP BY column1, column2   
HAVING conditions  
ORDER BY column1, column2;  
 
Example:
SELECT COMPANY, COUNT(*)  
FROM PRODUCT_MAST   
GROUP BY COMPANY  
HAVING COUNT(*)>2; 
Therefore an SQL query can contain a HAVING clause only if it has a GROUP BY clause.

Test: SQL - 3 - Question 8

In SQL selection is achieved by

Detailed Solution for Test: SQL - 3 - Question 8

Concept:
In SQL selection is achieved by SELECT..... FROM... WHERE. SQL selection is implemented through the WHERE clause of a SELECT statement. 

Example: 
Select *
from student
where course_name= "DBMS";
A basic selection of select statements can be implemented with from and where clause. The SQL SELECT command retrieves records from one or more tables and returns them as a result set. A SELECT command gets zero or more rows from one or more database tables or views. The most frequent data manipulation language (DML) command is SELECT in most applications.
Hence the correct answer is SELECT..... FROM... WHERE.

Test: SQL - 3 - Question 9

What is the full form of SQL?

Detailed Solution for Test: SQL - 3 - Question 9

SQL (Structured Query Language) is a standardized programming language that's used to manage relational databases and perform various operations on the data in them. ... SQL became the de facto standard programming language for relational databases after they emerged in the late 1970s and early 1980s.

  • SQL is regularly used not only by database administrators, but also by developers writing data integration scripts and data analysts looking to set up and run analytical queries.
  • The uses of SQL include modifying database table and index structures; adding, updating and deleting rows of data; and retrieving subsets of information from within a database for transaction processing and analytics applications.

Hence the correct answer is Structured Query Language.

Test: SQL - 3 - Question 10

Properties of ‘DELETE’ and ‘TRUNCATE’ commands indicate that

Detailed Solution for Test: SQL - 3 - Question 10

TRUNCATE

  • Is a DDL command hence it cannot be rolled back.
  • It resets the identity of the table and locks that state of the table.
  • Hence, Commit and Rollback will have no effect after TRUNCATE.
     

DELETE

  • Is a DML command hence it can be rolled back
  • It does not rest the identity of the table, it just locks the table row
  • Hence Commit and Rollback can have effect depending on the lock techniques used.

Hence, it can be said that after the execution of ‘TRUNCATE’ operation, COMMIT, and ROLLBACK statements cannot be performed to retrieve the lost data, while ‘DELETE’ allows it.

It can also be said that after the execution of ‘DELETE’ operation, COMMIT and ROLLBACK statements can be performed to retrieve the lost data, while TRUNCATE does not allow it

NOTE
In official ISRO CS 2020, both option 1 and 3 were correct and hence option is slightly modified to get only correct answer.

Information about Test: SQL - 3 Page
In this test you can find the Exam questions for Test: SQL - 3 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: SQL - 3, EduRev gives you an ample number of Online tests for practice

Top Courses for Computer Science Engineering (CSE)

Download as PDF

Top Courses for Computer Science Engineering (CSE)