0% found this document useful (0 votes)
8 views3 pages

SQL Lab Observation Note

The document outlines SQL operations for managing a student database, including creating tables, inserting records, updating names, and deleting entries. It provides examples of SQL commands and displays the resulting data for two student tables. The document also includes calculations for total marks based on individual subject scores.

Uploaded by

srishiva185
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)
8 views3 pages

SQL Lab Observation Note

The document outlines SQL operations for managing a student database, including creating tables, inserting records, updating names, and deleting entries. It provides examples of SQL commands and displays the resulting data for two student tables. The document also includes calculations for total marks based on individual subject scores.

Uploaded by

srishiva185
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
You are on page 1/ 3

SQL Lab Observation Note

Program Side

1. Student Table - Basic Operations

-- Create table
CREATE TABLE student (
name VARCHAR(50),
reg_no INT PRIMARY KEY,
department VARCHAR(50),
mark1 INT,
mark2 INT,
mark3 INT,
mark4 INT,
mark5 INT,
total INT
);

-- Insert Records
INSERT INTO student VALUES ('Anjali', 211278001, 'CS', 75, 80, 85, 70, 90, 0);
INSERT INTO student VALUES ('Rahul', 211278002, 'IT', 60, 70, 65, 75, 80, 0);
INSERT INTO student VALUES ('Sneha', 211278003, 'ECE', 90, 85, 80, 95, 85, 0);

-- Display all records


SELECT * FROM student;

-- Calculate total marks


UPDATE student SET total = mark1 + mark2 + mark3 + mark4 + mark5;

-- Display selected columns


SELECT name, reg_no, total FROM student;

2. Student Table - Update & Delete

-- Create table
CREATE TABLE student2 (
name VARCHAR(50),
reg_no INT PRIMARY KEY,
department VARCHAR(50),
mark1 INT,
mark2 INT,
mark3 INT,
mark4 INT,
mark5 INT,
total INT
);

-- Insert Records
INSERT INTO student2 VALUES ('Karthik', 211278005, 'MECH', 60, 65, 70, 75, 80, 0);
INSERT INTO student2 VALUES ('Ramya', 211278019, 'CIVIL', 85, 80, 90, 85, 75, 0);
INSERT INTO student2 VALUES ('Divya', 211278010, 'EEE', 70, 75, 80, 65, 60, 0);

-- Modify name
UPDATE student2 SET name = 'Vignesh' WHERE reg_no = 211278019;

-- Delete a record
DELETE FROM student2 WHERE reg_no = 211278005;

-- Display all records


SELECT * FROM student2;
Output Side

1. Student Table Output

After inserting:
| Name | Reg_No | Dept | M1 | M2 | M3 | M4 | M5 | Total |
|--------|-----------|------|----|----|----|----|----|-------|
| Anjali | 211278001 | CS | 75 | 80 | 85 | 70 | 90 | 0 |
| Rahul | 211278002 | IT | 60 | 70 | 65 | 75 | 80 | 0 |
| Sneha | 211278003 | ECE | 90 | 85 | 80 | 95 | 85 | 0 |

After calculating total:


| Name | Reg_No | Total |
|--------|-----------|-------|
| Anjali | 211278001 | 400 |
| Rahul | 211278002 | 350 |
| Sneha | 211278003 | 435 |

2. Student2 Table Output

After insert:
| Name | Reg_No | Dept | M1 | M2 | M3 | M4 | M5 | Total |
|----------|-----------|-------|----|----|----|----|----|-------|
| Karthik | 211278005 | MECH | 60 | 65 | 70 | 75 | 80 | 0 |
| Ramya | 211278019 | CIVIL | 85 | 80 | 90 | 85 | 75 | 0 |
| Divya | 211278010 | EEE | 70 | 75 | 80 | 65 | 60 | 0 |

After update:
| Name | Reg_No |
|----------|-----------|
| Vignesh | 211278019 |

After delete:
| Name | Reg_No | Dept | M1 | M2 | M3 | M4 | M5 | Total |
|----------|-----------|-------|----|----|----|----|----|-------|
| Vignesh | 211278019 | CIVIL | 85 | 80 | 90 | 85 | 75 | 0 |
| Divya | 211278010 | EEE | 70 | 75 | 80 | 65 | 60 | 0 |

You might also like