Answered step by step
Verified Expert Solution
Question
1 Approved Answer
SQL ASSIGNMENT Activity 1 : Create a table STUDENT with under mentioned structure by using SQL Statement: StdID Number Primary Key StdName Character ( 3
SQL ASSIGNMENT
Activity : Create a table STUDENT with under mentioned structure by using SQL Statement:
StdID Number Primary Key
StdName Character NOT NULL
Sex Character Male or Female
Percentage Number
SClass Number
Sec Character
Stream Character Science or Commerce
DOB Date Date of Birth
Step : Open MySQL Open Database and create table as:
CREATE TABLE Student
StdID INT PRIMARY KEY, StdName VARCHAR NOT NULL,
Sex VARCHAR Percentage DECIMAL SClass INT Sec VARCHAR Stream VARCHAR DOB DATE ;
Step : Press Enter keyto complete create table:
Step : Insert records into STUDENT table.
INSERT INTO Student VALUES AKSHRA AGARWAL,'FEMALE',A;
Step : As you press enter key after typing above statement, recordwill be stored into STUDENTtable.
Step: Similarly like step enter other records of the following table.
StdID StdName Sex Percentage Class Sec Stream DOB
AKSHRA AGARWAL FEMALE A Science
ANJANI SHARMA FEMALE A Commerce
ANSHUL SAXENA MALE A Commerce
AISHWARYA SINGH FEMALE A Commerce
AKRITI SAXENA FEMALE A Commerce
KHUSHI AGARWAL FEMALE A Commerce
MAAHI AGARWAL FEMALE A Science
MITALI GUPTA FEMALE A Science
NIKUNJ AGARWAL MALE A Science
PARKHI FEMALE A Commerce
PRAKHAR TIWARI MALE A Science
RAGHAV GANGWAR MALE A Commerce
SAHIL SARASWAT MALE A Commerce
SWATI MISHRA FEMALE A Science
HARSH AGARWAL MALE B Science
HARSHIT KUMAR MALE B Science
JAHANVI KAPOOR MALE B Science
STUTI MISHRA MALE C Commerce
SURYANSH KUMAR
AGARWAL
MALE
C
Commerce
TANI RASTOGI FEMALE C Commerce
TANISHK GUPTA MALE C Science
TANMAY AGARWAL MALE C Commerce
YASH SAXENA MALE C Science
YESH DUBEY MALE C Commerce
Activity : Open school database, then select student table and use following SQL statements.
TYPE THE STATEMENT, PRESS ENTER AND NOTE THE OUTPUT
To display all the records form STUDENT table.
SELECT FROM student ;
To display ony name and date of birth from the table STUDENT. SELECT StdName, DOB FROM student ;
To display all students record where percentage is greater of equal to FROM student table. SELECT FROM student WHERE percentage ;
To display student name, stream and percentage where percentage of student is more than SELECT StdName, Stream, Percentage WHERE percentage ;
To display all records of science students whose percentage is more than form student table. SELECT FORM student WHERE stream Science AND percentage ;
Activity : Open school database, then select student table and use following SQL statements.
TYPE THE STATEMENT, PRESS ENTER AND NOTE THE OUTPUT
To display the STUDENT table structure.
DESCRIBE Student;
To add a column FIELD in the STUDENT table, for example TeacherID as VARCHAR;
ALTER TABLE Student ADD TeacherID VARCHAR;
Type the statement
DESC Student;
Press enter key, now note the difference in table structure.
Type the statement and press enter key, note the new field that you have added as TeacherID
SELECT FROM student;
To modify the TeacherID data type form character to integer.
ALTER TABLE Student MODIFY TeacherID INTEGER ; DESC Student;
SELECT FROM student;
Activity
To Drop Delete a field form a table. For eg you want to delete TeacherID field.
ALTER TABLE Student DROP TeacherID;
To subtract form all students percentage and display name and percentage.
SELECT name, percentage FROM Student;
Using column alise for example we want to display StdName as Student Name and DOB as Date of Birth then the statement will be
SELECT StdName AS "Student Name",
DOB As Date of Birth FROM Student;
Display the name of all students whose stream is not Science
SELECT StdName FROMstudent WHERE Stream Science;
Display all name and percentage where percentage is between and
SELECT StdName, percentage FROM student WHERE percentage AND
percentage ;
Activity :
To change astudent name from SWATIMISHRA to SWATI VERMA whose StdID is and alsochange percentage
UPDATE Student SET StdName SWATI VERMA percentage
WHERE StdId ;
To delete the records form student table where StdId is
DELETE FROM Student WHERE StdID ;
Type the following SQL statement and note the output.
SELECT FROM Student WHERE StdName LIKE G ; SELECT FROM Student
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started