0% found this document useful (0 votes)
16 views5 pages

SQL Final Except 29

The document summarizes SQL commands used to create, populate, and manipulate a student table in a database. It includes creating the table, inserting 10 rows of data, altering the table by adding and modifying columns, updating a value, dropping a column, ordering the rows by date of birth, and using aggregation functions like min, max, and count to analyze the data.
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)
16 views5 pages

SQL Final Except 29

The document summarizes SQL commands used to create, populate, and manipulate a student table in a database. It includes creating the table, inserting 10 rows of data, altering the table by adding and modifying columns, updating a value, dropping a column, ordering the rows by date of birth, and using aggregation functions like min, max, and count to analyze the data.
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/ 5

PRACTICAL NUMBER:26

Aim: Create a student table and insert 10 row data. Implement the following SQL
commands on the student table: ALTER table to add new attributes/modify
data type/drop attribute; UPDATE table to modify data; ORDER By to
display data in ascending /descending order DELETE to remove tuple(s);
GROUP BY and find the min, max, sum.

● Creating Table

Source Code:
mysql> create table student (ROLLNO INT NOT NULL PRIMARY KEY,NAME
CHAR(10),Gender CHAR(10),DOB date, stream CHAR(10),PhoneNo
varchar(10),Location Char(10));
Query OK, 0 rows affected (0.30 sec)

Output:

Inserting Values Into Table

Source Code:
mysql> insert into student
values(01,"Bhaskar","M","2006-02-05","Science",9711980876, "Delhi"),
(02,"Prince ","M","2007-03-27","Science",9711980877, "Delhi"),
(03,"Keshav","M","2006-03-06","Science",9711980879,
"Delhi"),(04,"Shreya","F","2005-01-29","Science",9711980893, "Delhi"),
(05,"Srishti","F","2005-03-20","Arts",9711975876,
"Delhi"),(06,"Aditya","M","2003-09-29","Science",9711980674, "Delhi"),
(07,"Mantsha","M","2005-12-26","Commerce",9711980353, "Delhi"),
(08,"Roshan","M","2007-12-06","Science",9711982367, "Delhi"),
(09,"Neha","F","2005-02-24","Arts",9743980876, "Delhi"),
(10,"Akansha","F","2003-02-23","Arts",9711980870, "Delhi");
Query OK, 10 rows affected (0.08 sec)
Records: 10 Duplicates: 0 Warnings: 0

Output:
● Altering Table
Source Code:
mysql> alter table student add column Percentage
float(3,2); Query OK, 0 rows affected, 1 warning (0.12 sec)
Records: 0 Duplicates: 0 Warnings: 1

Output:

● Modifying Datatype of Percentage


Source Code:
mysql> alter table student modify column Percentage
float(6,2); Query OK, 0 rows affected, 1 warning (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 1

Output;

● Updating Table
Source Code:
mysql> update student set PhoneNo = 9399999999 where ROLLNO =
10; Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0

Output:

(Before Updating)

(After Updating)

● Dropping a Attribute

Source Code:
mysql> alter table student drop column Percentage;
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0

Output:

(Before Dropping)

● Order By

Source Code:
mysql> select * from student order by DOB;

Output:
● Group By

Source Code:
mysql> select min(DOB) as Min_DOB from student;

Output:

Source Code:
mysql> select max(DOB) as Max_DOB from student;

Output:

Source Code:
mysql> select count(DOB) as count_dob from student;
Output:

You might also like