SlideShare a Scribd company logo
1. Which of the following correctly creates a table named Students with columns ID (integer)
and Name (varchar of length 50)?
A) CREATE TABLE Students (ID int, Name varchar(50));
B) CREATE TABLE Students (ID integer, Name varchar[50]);
C) CREATE Students TABLE (ID int, Name varchar(50));
D) CREATE TABLE Students: ID int, Name varchar(50);
2. To add a new column Age of type integer to an existing table Students, which of the following
is correct?
A) ALTER TABLE Students ADD COLUMN Age int;
B) ALTER Students TABLE ADD COLUMN Age integer;
C) ALTER TABLE Students ADD Age integer;
D) MODIFY TABLE Students ADD Age int;
3. What is the correct syntax to add a PRIMARY KEY constraint on the ID column in the table
Students (assuming it's already created)?
A) ALTER TABLE Students ADD PRIMARY KEY (ID);
B) ALTER TABLE Students MODIFY ID PRIMARY KEY;
C) ALTER Students ADD CONSTRAINT PRIMARY KEY ID;
D) ADD PRIMARY KEY (ID) TO TABLE Students;
4. To create a table Courses with CourseID as primary key and CourseName as varchar, which
is correct?
A) CREATE TABLE Courses (CourseID int PRIMARY KEY, CourseName varchar(100));
B) CREATE TABLE Courses (CourseID int, PRIMARY KEY CourseID, CourseName
varchar(100));
C) CREATE TABLE Courses (CourseID PRIMARY KEY int, CourseName varchar(100));
D) CREATE TABLE Courses CourseID int PRIMARY KEY, CourseName varchar(100);
5. Which of the following is the correct way to add a NOT NULL constraint to the column Name
in the Students table?
A) ALTER TABLE Students MODIFY Name varchar(50) NOT NULL;
B) ALTER TABLE Students ALTER COLUMN Name SET NOT NULL;
C) ALTER TABLE Students ADD CONSTRAINT NOT NULL(Name);
D) ALTER Students SET NOT NULL FOR Name;
Answer: B (Note: Syntax can vary slightly based on DBMS — B works for PostgreSQL, A for
MySQL)

More Related Content

DOCX
HOLIDAY HOMEWORK FOR CLASS XII COMPUTER SC
PPTX
PYTHON MYSQL INTERFACE FOR CLASS XII STUDENTS
PDF
PRACTICAL RECORD FORMAT FOR TSUDENTS XI AND XII
PPTX
ARTIFICIAL INTELLIGENCE ETHICAL FRAMEWORK
PPTX
PPT ON PYTHON TOKENS FOR CLASS XI COMP SC
DOCX
Work sheet on introduction to emerging trends
DOCX
Emergingtreands class11 cs
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
HOLIDAY HOMEWORK FOR CLASS XII COMPUTER SC
PYTHON MYSQL INTERFACE FOR CLASS XII STUDENTS
PRACTICAL RECORD FORMAT FOR TSUDENTS XI AND XII
ARTIFICIAL INTELLIGENCE ETHICAL FRAMEWORK
PPT ON PYTHON TOKENS FOR CLASS XI COMP SC
Work sheet on introduction to emerging trends
Emergingtreands class11 cs
2024 Trend Updates: What Really Works In SEO & Content Marketing

Recently uploaded (20)

PDF
Anesthesia in Laparoscopic Surgery in India
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
master seminar digital applications in india
PDF
Pre independence Education in Inndia.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Insiders guide to clinical Medicine.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Pharma ospi slides which help in ospi learning
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
Anesthesia in Laparoscopic Surgery in India
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Renaissance Architecture: A Journey from Faith to Humanism
master seminar digital applications in india
Pre independence Education in Inndia.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Cell Structure & Organelles in detailed.
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Institutional Correction lecture only . . .
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Module 4: Burden of Disease Tutorial Slides S2 2025
Insiders guide to clinical Medicine.pdf
O7-L3 Supply Chain Operations - ICLT Program
Pharma ospi slides which help in ospi learning
Microbial disease of the cardiovascular and lymphatic systems
Week 4 Term 3 Study Techniques revisited.pptx
Ad
Ad

SQL QUESTIONS FOR CLASS XII CS AND IP STUDENTS

  • 1. 1. Which of the following correctly creates a table named Students with columns ID (integer) and Name (varchar of length 50)? A) CREATE TABLE Students (ID int, Name varchar(50)); B) CREATE TABLE Students (ID integer, Name varchar[50]); C) CREATE Students TABLE (ID int, Name varchar(50)); D) CREATE TABLE Students: ID int, Name varchar(50); 2. To add a new column Age of type integer to an existing table Students, which of the following is correct? A) ALTER TABLE Students ADD COLUMN Age int; B) ALTER Students TABLE ADD COLUMN Age integer; C) ALTER TABLE Students ADD Age integer; D) MODIFY TABLE Students ADD Age int; 3. What is the correct syntax to add a PRIMARY KEY constraint on the ID column in the table Students (assuming it's already created)? A) ALTER TABLE Students ADD PRIMARY KEY (ID); B) ALTER TABLE Students MODIFY ID PRIMARY KEY; C) ALTER Students ADD CONSTRAINT PRIMARY KEY ID; D) ADD PRIMARY KEY (ID) TO TABLE Students; 4. To create a table Courses with CourseID as primary key and CourseName as varchar, which is correct? A) CREATE TABLE Courses (CourseID int PRIMARY KEY, CourseName varchar(100)); B) CREATE TABLE Courses (CourseID int, PRIMARY KEY CourseID, CourseName varchar(100)); C) CREATE TABLE Courses (CourseID PRIMARY KEY int, CourseName varchar(100)); D) CREATE TABLE Courses CourseID int PRIMARY KEY, CourseName varchar(100); 5. Which of the following is the correct way to add a NOT NULL constraint to the column Name in the Students table? A) ALTER TABLE Students MODIFY Name varchar(50) NOT NULL; B) ALTER TABLE Students ALTER COLUMN Name SET NOT NULL;
  • 2. C) ALTER TABLE Students ADD CONSTRAINT NOT NULL(Name); D) ALTER Students SET NOT NULL FOR Name; Answer: B (Note: Syntax can vary slightly based on DBMS — B works for PostgreSQL, A for MySQL)