0% found this document useful (0 votes)
8 views10 pages

SQL Test

The document consists of a series of SQL-related questions, covering topics such as SQL commands, clauses, operators, and their purposes. It includes multiple-choice questions, short answer questions, and long answer questions that require SQL command writing. The questions address various aspects of SQL, including data manipulation, retrieval, and database management.

Uploaded by

nishisultania.sy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views10 pages

SQL Test

The document consists of a series of SQL-related questions, covering topics such as SQL commands, clauses, operators, and their purposes. It includes multiple-choice questions, short answer questions, and long answer questions that require SQL command writing. The questions address various aspects of SQL, including data manipulation, retrieval, and database management.

Uploaded by

nishisultania.sy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Q.1 A is a subset of DML that just deals with information retrieval.

(B) Query Language


(C) Structure Language
(D) Both a) and b)
(E) None of the above

A is a language that enables users to access and


Q2 manipulate data in a database.

(F) Data Manipulation Language (DML)


(G) Data Definition Language (DDL)
(H) Both a) and b)
(I) None of the above

Ques.3 What SQL clause is used to specify the columns you want to retrieve from a
table?
(A) SELECT
(B) FROM
(C) WHERE
(D) INSERT

Ques.4 Which SQL clause specifies the table from which data should be retrieved?
(A) SELECT
(B) FROM
(C) WHERE
(D) UPDATE

Ques.5 What SQL operator is used for exact value matching in a WHERE clause?
(A) LIKE
(B) BETWEEN
(C) =
(D) AND

Ques.6 Which SQL operator is used to check if a column value falls within a specified
range?
(A) LIKE
(B) BETWEEN
(C) =
(D) AND

Ques.7 What is the purpose of the IS NULL operator in SQL?


(A) It checks if a column contains a specific value.
(B) It checks if a column is empty.
(C) It checks if a column is not empty.
(D) It checks if a column exists.
Ques. 8 Which logical operator combines multiple conditions in a
WHERE clause with an OR relationship?
(A) AND
(B) OR
(C) NOT
(D) XOR

Ques. 9 What SQL statement is used to add new records to a database


table?
(A) INSERT
(B) DELETE
(C) UPDATE
(D) ALTER

Ques. 10 Which SQL clause is used to delete records from a database table?
(A) INSERT
(B) DELETE
(C) UPDATE
(D) ALTER

Ques.11 Which SQL clause is used to modify existing records in a database


table?
(A) INSERT
(B) DELETE
(C) UPDATE
(D) ALTER

Ques.12 Which SQL statement is used to remove all records from a table?
(A) TRUNCATE
(B) DROP
(C) DELETE
(D) REMOVE

Ques.13 What does the SQL WHERE clause do?


(A) It specifies which columns to retrieve.
(B) It filters the rows to include based on a condition.
(C) It specifies the table to query.
(D) It sorts the result set.

Ques.14 What is the purpose of the NOT operator in a SQL WHERE clause?
(A) It negates a condition.
(B) It checks if a column is empty.
(C) It checks if a column exists.
(D) It combines conditions with OR.
Ques.15 Which SQL clause is used to update data in a table with new
values?
(A) INSERT
(B) DELETE
(C) UPDATE
(D) ALTER

Ques.16 What SQL operator is used for pattern matching in a WHERE


clause?
(A) LIKE
(B) BETWEEN
(C) =
(D) AND
Ques.17 Which SQL operator checks if a column value is not equal to a
specified value in a WHERE clause?
(A) LIKE
(B) BETWEEN
(C) <>
D) AND
Ques.18 Which SQL statement is used to retrieve data from a database?
(A) UPDATE
(B) DELETE
(C) INSERT
(D) SELECT

Ques.19 Which command should be used to change the datatype of a column in an SQL
table?
A) CREATE
B) ALTER
C) DROP
D) TRUNCATE
Very Short Answer Type Questions (10)

Ques. 1 Write the full form of DDL and DML.

Ques.2 What is a NULL Value?

Ques.3 Find the error in the following query and rewrite it:
DELETE * FROM STUDENT;

Ques.4 Categorize the following SQL commands into DDL and DML :
CREATE, UPDATE, INSERT, DROP

Ques.5 Correct the error in the following query.


Select * from RECORD where Rname = %math%;

Ques.6 Explain the purpose of the SQL SELECT statement and provide an example of
how it is used to retrieve specific data from a database table.

Ques.7 How can you eliminate duplicate records in a table with SELECT query?

Ques. 8 Write a command that deletes all details for customer SOHAN from table
customer.

Ques.9 Which command is used to view the list of tables in a database?

Ques.10 In SQL , what is the use of IS NULL OPERATOR?


Short Answer Type Questions (10)

Ques.1 Describe the primary function of the SQL INSERT statement and provide an example
of how it is used to add new records to a database table.

Ques.2 You have a database table named "Students" with columns "StudentID," "FirstName,"
"LastName," and "Age." Write an SQL query to delete all students below the age of 18.

Ques.3 Explain the purpose of the SQL SELECT statement and provide an example of how it
is used to retrieve specific data from a database table.

Ques.4 What are DDL and DML statements?

Ques.5 Explain the difference between DELETE and TRUNCATE commands.

Ques. 6 Describe the SELECT statement.


Ans.

Ques. 7 Differentiate between Alter and Update command.


Ques.8 How can you add a new column or a constraint in a table?

Ques.9 Write a query to display details of all those employees from EMPLOYEE table

Ques. 10 Write a query to display details of all those employees from EMPLOYEE table
LONG ANSWER TYPE QUESTIONS (5)

Ques1 Consider the following table EMPLOYEE.

Write SQL commands for (i) to (vi):


(i) To display the details of all employees.
(ii) To display NAME and DESIGN of those employees whose SALGRADE is
either S02 or S03.
(iii) To display details of the employees whose DOJ is between '09-02- -
08-2009'.
(iv) To add a new row with the following content:
-IT', 'S02', '9-09- -04-1983', 32000, 12000)
(v) To display the details of all employees whose Salary is greater than 30000.
(vi) To display list of all unique SGrade
Ques2 Write the SQL commands for (a) to (e) on the basis of table SPORTS:

a) Display the names of the students who have grade 'C' in either Game1 or Game2
or both.
(b) Display the details of students getting grade 'A' in Cricket.
(c) Display the names of the students who have same game for both Game1 and
Game2.
(d) Display the games taken up by the students whose name is 'Arpit'.
(e) Adda new column named 'Marks'.

Ques3 Write SQL commands to perform the following tasks:


(a) Create a database 'Hospital'.

(c) Create a table 'Doctor' with the following structure:

(d)Display the structure of the table 'Doctor.


(e) Add one more column Date_ of_ Joining with Date data type.
(f) Insert the following record in a table:
D01, Dr. Vaibhav Singh, ENT, 99XXXX, Paschim Vihar, 7800, 2010-10-12 .
(g) Change the data type of column Doc Name from Varchar(30) to Varchar(50).
(h) Rename the column MobileNo to ContactNo.
(i) Delete the column Address.
(j) Delete the table 'Doctor'.

Ques.4 Explain IN, BETWEEN and LIKE operators in SQL with examples.

Ques.5 Write the output of the following commands:


(i) SELECT MATCH_ID FROM MATCH DETAILS WHERE TEAM2_ SCORE
BETWEEN 40 AND 60;
(ii) SELECT TEAM1_SCORE+1 FROM MATCH DETAILS WHERE
TEAM1_ID=1;
(iii) SELECT TEAM1_ID, TEAM2_ID FROM MATCH DETAILS WHERE
TEAM1_SCORE<70 AND TEAM2_SCORE<70;
(iv) SELECT MATCH ID FROM MATCH _DETAILS WHERE MATCH _DATE
LIKE"%-19";
studentID studName sCode marks
1002 Rama ABC 90
1004 Anurag XYZ 70
1009 Raj PQR 85
1008 Aruna PQR 80
1020 Anish ABC 79
1024 Diksha XYZ 84
1031 Sahil ABC 88

You might also like