0% found this document useful (0 votes)
7 views8 pages

Sr-Ip-Sample Q&A For SQL Commands

The document provides a series of sample SQL questions and answers focused on creating and manipulating a student table, including commands for creating tables, inserting records, and selecting data with various conditions. It covers fundamental SQL concepts such as primary keys, unique constraints, and data selection criteria. The examples illustrate practical applications of SQL commands for managing student information.

Uploaded by

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

Sr-Ip-Sample Q&A For SQL Commands

The document provides a series of sample SQL questions and answers focused on creating and manipulating a student table, including commands for creating tables, inserting records, and selecting data with various conditions. It covers fundamental SQL concepts such as primary keys, unique constraints, and data selection criteria. The examples illustrate practical applications of SQL commands for managing student information.

Uploaded by

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

SAMPLE QUESTIONS & ANSWERS FOR BASIC SQL COMMANDS

Q1: How do you create a simple student table with ID, name, and class?

✅ Answer:

CREATE TABLE STUDENT (

StudentID INT,

Name VARCHAR(100),

Class VARCHAR(20)

);

Q2: How do you create a student table with a primary key?

✅ Answer:

CREATE TABLE STUDENT (

StudentID INT PRIMARY KEY,

Name VARCHAR(100),

Age INT

);

Q3: How do you ensure that the Name column is not left empty?

✅ Answer:

CREATE TABLE STUDENT (

StudentID INT PRIMARY KEY,


Name VARCHAR(100) NOT NULL,

Age INT
);
Q4: How do you create a student table with a unique email column?

✅ Answer:

CREATE TABLE STUDENT (

StudentID INT PRIMARY KEY,

Name VARCHAR(100),

Email VARCHAR(100) UNIQUE

);

Q5: How do you create a student table with gender, phone, and address?

✅ Answer:

CREATE TABLE STUDENT (

StudentID INT PRIMARY KEY,

Name VARCHAR(100),

Gender CHAR(1),

Phone VARCHAR(15),
Address TEXT
);

Q6: How do you insert a single student record into a table?

✅ Answer:

INSERT INTO STUDENT (StudentID, Name, Class)

VALUES (1, 'John Doe', '10A');


Q7: How do you insert multiple student records at once?

✅ Answer:

INSERT INTO STUDENT (StudentID, Name, Class)

VALUES

(2, 'Alice Smith', '10B'),

(3, 'Rahul Kumar', '10A'),

(4, 'Sara Lee', '10C');

Q8: How do you insert 5 student records into the STUDENT table?

✅ Answer:

INSERT INTO STUDENT (StudentID, Name, Age, Gender, Class, Phone, Email,
AdmissionDate) VALUES

(1, 'Arun Kumar', 16, 'M', '10A', '9876543210', 'arun@[Link]', '2025-06-12'),

(2, 'Priya Rani', 15, 'F', '10B', NULL, 'priya@[Link]', '2025-06-15'),

(3, 'John Peter', 14, 'M', '9A', '9900011122', NULL, '2025-06-18'),

(4, 'Anjali Sharma', 15, 'F', '10A', '9911223344', 'anjali@[Link]', '2025-06-20'),

(5, 'David Lee', 17, 'M', '11C', NULL, NULL, '2025-07-01');

Q9: How do you insert a record with all columns, including date and phone?

✅ Answer:

INSERT INTO STUDENT (StudentID, Name, Gender, Phone, AdmissionDate)

VALUES (5, 'David Paul', 'M', '9876543210', '2025-07-08');


Q10: How do you insert a record without specifying column names (not
recommended)?

✅ Answer:

INSERT INTO STUDENT

VALUES (7, 'Ravi Kumar', 'M', '10B', '2025-07-08');

 Make sure the values are in exact column order as defined in the table.

Q11: How do you insert a record with a unique email?

✅ Answer:

INSERT INTO STUDENT (StudentID, Name, Email)

VALUES (8, 'Neha Reddy', '[Link]@[Link]');

Q12: How do you select all columns from the student table?

✅ Answer:

SELECT * FROM STUDENT;

Q13: How do you select only the name and class of all students?

✅ Answer:

SELECT Name, Class FROM STUDENT;


Q14: How do you select records where the class is '10A'?

✅ Answer:

SELECT * FROM STUDENT

WHERE Class = '10A';

Q15: How do you find students older than 15 years?

✅ Answer:

SELECT * FROM STUDENT


WHERE Age > 15;

Q16: How do you find the names of female students only?

✅ Answer:

SELECT Name FROM STUDENT


WHERE Gender = 'F';

Q17: How do you select students with names starting with 'A'?

✅ Answer:

SELECT * FROM STUDENT


WHERE Name LIKE 'A%';
Q18: How do you find students admitted after July 1, 2025?

✅ Answer:

SELECT * FROM STUDENT

WHERE AdmissionDate > '2025-07-01';

Q19: How do you select distinct classes from the student table?

✅ Answer:

SELECT DISTINCT Class FROM STUDENT;

_____________________________________________________________________

Q&A style examples for the SQL SELECT command** using special conditions
like BETWEEN, IN, NOT IN, and IS NULL with the STUDENT table.

Q1: How do you select students whose age is between 15 and 18?

✅ Answer:

SELECT * FROM STUDENT


WHERE Age BETWEEN 15 AND 18;

 BETWEEN includes both boundary values (i.e., 15 and 18).

Q2: How do you find students whose age is not between 10 and 14?

✅ Answer:

SELECT * FROM STUDENT


WHERE Age NOT BETWEEN 10 AND 14;
Q3: How do you select students who are in classes '10A', '10B', or '10C'?

✅ Answer:

SELECT * FROM STUDENT

WHERE Class IN ('10A', '10B', '10C');

 IN is used for checking multiple matching values.

Q4: How do you select students who are not in classes '9A' or '9B'?

✅ Answer:

SELECT * FROM STUDENT

WHERE Class NOT IN ('9A', '9B');

 NOT IN excludes values from the result.

Q5: How do you find students whose phone number is not entered (i.e., phone is
NULL)?

✅ Answer:

SELECT * FROM STUDENT

WHERE Phone IS NULL;

 IS NULL checks if a column has no value.


Q6: How do you find students whose email is missing?

✅ Answer:

SELECT * FROM STUDENT

WHERE Email IS NULL;

Q7: How do you find students whose admission date is between '2025-06-01' and
'2025-07-01'?

✅ Answer:

SELECT * FROM STUDENT

WHERE AdmissionDate BETWEEN '2025-06-01' AND '2025-07-01';

Q8: How do you find students whose gender is either 'M' or 'F'?

✅ Answer:

SELECT * FROM STUDENT

WHERE Gender IN ('M', 'F');

Q9: How do you find students whose age is not between 10 and 14?

✅ Answer:

SELECT * FROM STUDENT

WHERE Age NOT BETWEEN 10 AND 14;

You might also like