Test Index

Structured Query Language (SQL) Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 40 of 58
Marks: +1, -0
(a) Mr. Atharva is given a task to create a database, Admin. He has to create a table, users in the database with the following columns : (1+1=2)
User_id - int
User_name - varchar(20)
Password - varchar(10)
Help him by writing SQL queries for both tasks.
OR
(b) Ms. Rita is a database administrator at a school. She is working on the table, student containing the columns like Stud_id, Name, Class and Stream. She has been asked by the Principal to strike off the record of a student named Rahul with student_id as 100 from the school records and add another student who has been admitted with the following details : (1+1=2)
Stud_id - 123
Name - Rajeev
Class - 12
Stream - Science
Help her by writing SQL queries for both tasks.
[CBSE 2024 Compartment]
Solution:  
(a)
Creating the database:
CREATE DATABASE Admin;
Creating the table (after USE Admin;):
CREATE TABLE users
(
User_id INT,
User_name VARCHAR(20),
Password VARCHAR(10)
);
OR (b)
Removing Rahul's record:
DELETE FROM student
WHERE Stud_id = 100 AND Name = 'Rahul';
Adding the new student:
INSERT INTO student (Stud_id, Name, Class, Stream)
VALUES (123, 'Rajeev', 12, 'Science');
DELETE with a WHERE clause removes only the matching row; INSERT INTO ... VALUES adds a new row with the values in column order.
© examsnet.com
Advertisements
Go to Question: