0% found this document useful (0 votes)
8 views

DBMS_2nd Expt (1)

The document outlines a series of MySQL commands executed to create and manage a database table named STUDENT_LAB2, which stores student information including USN, Name, Date of Birth, Branch, Marks, Total, and GPA. It includes commands for inserting, updating, selecting, and deleting records, as well as calculating totals and GPAs. The final output shows the current state of the table after various operations, including the deletion of a record.

Uploaded by

er.poojab45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

DBMS_2nd Expt (1)

The document outlines a series of MySQL commands executed to create and manage a database table named STUDENT_LAB2, which stores student information including USN, Name, Date of Birth, Branch, Marks, Total, and GPA. It includes commands for inserting, updating, selecting, and deleting records, as well as calculating totals and GPAs. The final output shows the current state of the table after various operations, including the deletion of a record.

Uploaded by

er.poojab45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

DBMS- EXPERIMENT-02

mysql> USE DBMSLAB;


Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> CREATE TABLE STUDENT_LAB2(USN varchar(10) primary key,
Name Char(15) not null,
Date_of_birth Date null,
Branch char(15) not null,
Marks1 integer not null, Marks2 integer not null,
Marks3 integer not null,
Total integer,
GPA real);
Query OK, 1 row affected (0.03 sec)

mysql> INSERT INTO STUDENT_LAB2 (USN, Name, Date_of_birth, Branch, Marks1, Marks2, Marks3, GPA)
-> VALUES ('2JI150MC01', 'GAURAV', '1999-07-12', 'MCA', 75, 86, 72, 8.5);
Query OK, 1 row affected (0.03 sec)

mysql> INSERT INTO STUDENT_LAB2 (USN, Name, Date_of_birth, Branch, Marks1, Marks2, Marks3, GPA)
-> VALUES ('2JI150CC10', 'JAI', '1998-01-02', 'COMM', 75, 86, 70, 8.4);
Query OK, 1 row affected (0.03 sec)

mysql> INSERT IGNORE INTO STUDENT_LAB2 (USN, Name, Date_of_birth, Branch, Marks1, Marks2,
Marks3, GPA)
-> VALUES ('2JI150CC10', 'JAI', '1998-01-02', 'COMM', 75, 86, 70, 8.4);
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> INSERT INTO STUDENT_LAB2 (USN, Name, Date_of_birth, Branch, Marks1, Marks2, Marks3, GPA)
-> VALUES ('2JI150SC09', 'DEEPAK', '999-12-12', 'SCIENCE', 72, 86, 72, 8.3); Query OK, 1 row affected
(0.02 sec)

mysql> INSERT INTO STUDENT_LAB2 (USN, Name, Date_of_birth, Branch, Marks1, Marks2, Marks3, GPA)
-> VALUES ('2JI180MC01', 'ABHI', '1996-02-27', 'ARTS', 80, 86, 72, 9.0);
Query OK, 1 row affected (0.04 sec)

mysql> INSERT INTO STUDENT_LAB2 (USN, Name, Date_of_birth, Branch, Marks1, Marks2, Marks3, GPA)
-> VALUES ('2JI150MC45', 'SAI', '1999-08-15', 'MCA', 75, 86, 50, 7.2);
Query OK, 1 row affected (0.03 sec)

mysql> SELECT * FROM STUDENT_LAB2;


USN Name Date_of_birth Branch Marks1 Marks2 Marks3 | Total GPA
2JI150CC10 JAI 1998-01-02 COMM 75 86 | 70 NULL | 8.4
2JI150MC0 GAURAV 1999-07-12 MCA 75 86 72 NULL | 8.5
2JI150MC4 SAI 1999-08-15 MCA 75 86 50 NULL 7.2
5
2JI150SC09 DEEPAK 0999-12-12 SCIENCE 72 86 72 NULL 8.3
2JI180MC01 ABHI 1996-02-27 ARTS 80 86 72 NULL 9

5 rows in set (0.00 sec)


mysql> UPDATE STUDENT_LAB2 SET Total = Marks1 + Marks2 + Marks3;
Query OK, 5 rows affected (0.03 sec)
Rows matched: 5 Changed: 5 Warnings: 0

mysql> SELECT * FROM STUDENT_LAB2;


USN Name Date_of_birth Branch Marks1 Marks2 Marks3 | Total GPA
2JI150CC10 JAI 1998-01-02 COMM 75 86 | 70 231 8.4
2JI150MC0 GAURAV 1999-07-12 MCA 75 86 72 233 8.5
2JI150MC4 SAI 1999-08-15 MCA 75 86 50 211 7.2
5
2JI150SC09 DEEPAK 0999-12-12 SCIENCE 72 86 72 230 8.3
2JI180MC01 ABHI 1996-02-27 ARTS 80 86 72 238 9

5 rows in set (0.00 sec)

mysql> UPDATE STUDENT_LAB2 SET GPA = (Total/3.0);


Query OK, 5 rows affected (0.06 sec)
Rows matched: 5 Changed: 5 Warnings: 0

mysql> UPDATE STUDENT_LAB2 SET GPA = (Total/3.0);


Query OK, 0 rows affected (0.03 sec)
Rows matched: 5 Changed: 0 Warnings: 0

mysql> SELECT * FROM STUDENT_LAB2;


USN Name Date_of_birth Branch Marks1 Marks2 Marks3 |Total GPA
2JI150CC10 JAI 1998-01-02 COMM 75 86 | 70 231 77
2JI150MC0 GAURAV 1999-07-12 MCA 75 86 72 233 77.666666666
2JI150MC4 SAI 1999-08-15 MCA 75 86 50 211 70.333333333
5
2JI150SC09 DEEPAK 0999-12-12 SCIENC 72 86 72 230 76.666666666
E
2JI180MC01 ABHI 1996-02-27 ARTS 80 86 72 238 79.333333333

5 rows in set (0.00 sec)

mysql> SELECT USN,NAME,DATE_OF_BIRTH FROM STUDENT_LAB2 WHERE Date_of_birth like


'1999______';
+------------+--------+---------------+
| USN | NAME | DATE_OF_BIRTH |
+------------+--------+---------------+
| 2JI150MC01 | GAURAV | 1999-07-12 |
| 2JI150MC45 | SAI | 1999-08-15 |
+------------+--------+---------------+
2 rows in set, 1 warning (0.00 sec)

mysql> SELECT USN, NAME, BRANCH FROM STUDENT_LAB2 WHERE BRANCH = 'MCA';
+------------+--------+--------+
| USN | NAME | BRANCH |
+------------+--------+--------+
| 2JI150MC01 | GAURAV | MCA |
| 2JI150MC45 | SAI | MCA |
+------------+--------+--------+
2 rows in set (0.00 sec)

mysql> SELECT USN,BRANCH,MAX(GPA) AS MAX_GPA


-> FROM STUDENT_LAB2
-> GROUP BY USN,BRANCH
-> ORDER BY MAX_GPA DESC;
+------------+---------+--------------+
| USN | BRANCH | MAX_GPA |
+------------+---------+--------------+
| 2JI180MC01 | ARTS | 79.333333333 |
| 2JI150MC01 | MCA | 77.666666666 |
| 2JI150CC10 | COMM | 77 |
| 2JI150SC09 | SCIENCE | 76.666666666 |
| 2JI150MC45 | MCA | 70.333333333 |
+------------+---------+--------------+
5 rows in set (0.00 sec)

mysql> SELECT USN,NAME FROM STUDENT_LAB2 WHERE Name LIKE 'S%';


+------------+------+
| USN | NAME |
+------------+------+
| 2JI150MC45 | SAI |
+------------+------+
1 row in set (0.00 sec)

mysql> INSERT INTO STUDENT_LAB2 (USN, Name, Date_of_birth, Branch, Marks1, Marks2, Marks3, Total,
GPA)
-> VALUES ('2JI150MC50', 'TENDULKAR', '1970-04-25', 'MCA', 75, 86, 70, 0, 0);
Query OK, 1 row affected (0.02 sec)

mysql> SELECT USN, Name


-> FROM STUDENT_LAB2
-> WHERE Name LIKE '%AR';
+------------+-----------+
| USN | Name |
+------------+-----------+
| 2JI150MC50 | TENDULKAR |
+------------+-----------+
1 row in set (0.00 sec)

mysql> DELETE
-> FROM STUDENT_LAB2
-> WHERE USN = '2JI150CC10';
Query OK, 1 row affected (0.03 sec)

mysql> SELECT * FROM STUDENT_LAB2;


USN Name Date_of_birt Branch Marks Marks Marks | GPA
h 1 2 3 Total
2JI150MC01 GAURAV 1999-07-12 MCA 75 86 72 233 77.66666666
6
2JI150MC4 SAI 1999-08-15 MCA 75 86 50 211 70.33333333
5 3
2JI150MC50 TENDULKA 1970-04-25 MCA 75 86 70 0 0
R
2JI150SC09 DEEPAK 0999-12-12 SCIENC 72 86 72 230 76.66666666
E 6
2JI180MC01 ABHI 1996-02-27 ARTS 80 86 72 238 79.33333333
3
5 rows in set (0.00 sec)

You might also like