0% found this document useful (0 votes)
14 views2 pages

SQL Operations on Student Table Guide

This document outlines SQL operations on a 'Student' table, including creating the table, inserting data, altering the schema, updating records, sorting, deleting entries, and using aggregate functions. It provides specific SQL commands for each operation, such as creating the table with columns for RollNo, Name, Class, and Marks, and demonstrates how to manipulate the data. Additionally, it shows how to group data by Gender and calculate various statistics on Marks.

Uploaded by

sahil.98306
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)
14 views2 pages

SQL Operations on Student Table Guide

This document outlines SQL operations on a 'Student' table, including creating the table, inserting data, altering the schema, updating records, sorting, deleting entries, and using aggregate functions. It provides specific SQL commands for each operation, such as creating the table with columns for RollNo, Name, Class, and Marks, and demonstrates how to manipulate the data. Additionally, it shows how to group data by Gender and calculate various statistics on Marks.

Uploaded by

sahil.98306
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

SQL Operations on Student Table

This document demonstrates various SQL operations performed on a `Student` table. The

commands include creating a table, inserting data, altering table schema, updating data, sorting

records, deleting entries, and applying aggregate functions using GROUP BY.

1. Create Table and Insert Data

CREATE TABLE Student (


RollNo INT PRIMARY KEY,
Name VARCHAR(50),
Class VARCHAR(10),
Marks INT
);

INSERT INTO Student VALUES (101, 'Alice', 'XII-A', 85);


INSERT INTO Student VALUES (102, 'Bob', 'XII-B', 90);
INSERT INTO Student VALUES (103, 'Charlie', 'XII-A', 78);

2. ALTER Table

-- Add new column


ALTER TABLE Student ADD Gender VARCHAR(10);

-- Modify data type


ALTER TABLE Student MODIFY Marks FLOAT;

-- Drop column
ALTER TABLE Student DROP COLUMN Class;

3. UPDATE Table

UPDATE Student SET Marks = 95 WHERE RollNo = 102;

4. ORDER BY

-- Ascending order
SELECT * FROM Student ORDER BY Marks ASC;

-- Descending order
SELECT * FROM Student ORDER BY Marks DESC;
Page 2

5. DELETE Tuples

DELETE FROM Student WHERE Marks < 80;

6. GROUP BY with Aggregates

SELECT Gender,
COUNT(*) AS Count,
MIN(Marks) AS MinMarks,
MAX(Marks) AS MaxMarks,
SUM(Marks) AS TotalMarks,
AVG(Marks) AS AverageMarks
FROM Student
GROUP BY Gender;

You might also like