mysql_DPS_lab record_xi
mysql_DPS_lab record_xi
I. Create a table student with attributes like sno, sname, marks, address and city
mysql> create table student(sno int(3), sname varchar(20), marks int(4),address varchar(10),city
varchar(10));
+---------+-------------+------+-----+---------+-------+
+---------+-------------+------+-----+---------+-------+
+---------+-------------+------+-----+---------+-------+
5 rows in set
II. Create a table student with attributes like sno, sname, marks, address and city , set sno as
primary key and not null. Sname is not null.
mysql> create table stud_new(sno int(3) not null primary key, sname varchar(20)
+--------+-------------+------+-----+---------+-------+
+--------+-------------+------+-----+---------+-------+
III. Insert the values into student table which we created earlier.
'm',423,'2000-01-09'),(6,'nandini','f',432,'1999-12-31');
+-----+----------+--------+-------+------------+
+-----+----------+--------+-------+------------+
+-----+----------+--------+-------+------------+
V. Update the student table with new marks for student number “6”
+-----+----------+--------+-------+------------+
+-----+----------+--------+-------+------------+
6 rows in set
VI. Add five extra marks to the student whose student number is ‘1’
+-----+----------+--------+-------+------------+
+-----+----------+--------+-------+------------+
+-----+----------+--------+-------+------------+
VII. Update the student table marks by adding eight to original marks to roll number three or six
+-----+----------+--------+-------+------------+
+-----+----------+--------+-------+------------+
Query OK,
+-----+----------+--------+-------+------------+
+-----+----------+--------+-------+------------+
+-----+----------+--------+-------+------------+
IX. Display the student name, number and gender of student table
+----------+-----+--------+
| anil | 1|m |
| aravinda | 3 | f |
| aravind | 4 | m |
| anand | 5 | m |
| nandini | 6 | f |
+----------+-----+--------+
X. Display the student name, number and gender of student table where the gender is female.
+----------+-----+--------+
+----------+-----+--------+
| aravinda | 3 | f |
| nandini | 6 | f |
+----------+-----+--------+
and '1990-12-30';
+----------+-----+--------+------------+
+----------+-----+--------+------------+
| aravinda | 3 | f | 1990-07-09 |
| aravind | 4 | m | 1990-03-29 |
+----------+-----+--------+------------+
XII. Entering “null values” if the value of a record is not known to the user.
mysql> insert into stud_new values(7,'aravind','m',499,null);
Query OK,
+-----+----------+--------+-------+------------+
+-----+----------+--------+-------+------------+
+-----+----------+--------+-------+------------+
+---------------------+
| Database |
+---------------------+
| information_schema |
| 11B |
| 11astudents |
| mysql |
| student |
| DPS |
| test |
| xiic_students |
| xiiBstudents |
+---------------------+
2. To create the databases in our computer with our name (mysql client version)
Query OK,
Query OK,
Query OK,
5.Delete a table
Query OK,
+--------------+
| Tables_in_db |
+--------------+
| new_student |
+--------------+
XIV. Applying Alter command on student table
Query OK,
+---------+-------------+------+-----+---------+-------+
+---------+-------------+------+-----+---------+-------+
+---------+-------------+------+-----+---------+-------+
2. Adding a new column ”COURSE” to stud_new table with a default value “MPC”.
Query OK,
3. Removing a column
Query OK,
Query OK,
*****************