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

TABLE 6

The document outlines the process of creating a MySQL database named 'ABC' and a table 'STU' with various student attributes. It includes commands for inserting records, updating a student's name, and displaying all records, as well as dropping the table. The document demonstrates basic SQL operations and their outcomes, including the structure of the table and the results of queries executed.

Uploaded by

jangratanisha26
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)
18 views3 pages

TABLE 6

The document outlines the process of creating a MySQL database named 'ABC' and a table 'STU' with various student attributes. It includes commands for inserting records, updating a student's name, and displaying all records, as well as dropping the table. The document demonstrates basic SQL operations and their outcomes, including the structure of the table and the results of queries executed.

Uploaded by

jangratanisha26
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/ 3

Creating Database and Table 6

mysql> CREATE DATABASE ABC;


Query OK, 1 row affected (0.01 sec)

mysql> USE ABC;


Database changed

mysql> CREATE TABLE STU( Roll_No INT(2), Name VARCHAR(25), Eng INT(2),
Hindi INT(2), Math INT(2), Science INT(2), IT INT(2));
Query OK, 0 rows affected, 6 warnings (0.03 sec)

mysql> DESC STU;

+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| Roll_No | int | YES | | NULL | |
| Name | varchar(25) | YES | | NULL | |
| Eng | int | YES | | NULL | |
| Hindi | int | YES | | NULL | |
| Math | int | YES | | NULL | |
| Science | int | YES | | NULL | |
| IT | int | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
7 rows in set (0.01 sec)
Queries
1. Display all the Records.

mysql> SELECT*FROM STU;


+---------+--------+------+-------+------+---------+------+
| Roll_No | Name | Eng | Hindi | Math | Science | IT |
+---------+--------+------+-------+------+---------+------+
| 1 | AMAN | 67 | 56 | 45 | 72 | 87 |
| 2 | HEENA | 81 | 78 | 65 | 82 | 97 |
| 3 | MUKESH | 59 | 69 | 58 | 70 | 55 |
| 3 | MUKESH | 69 | 75 | 88 | 79 | 78 |
+---------+--------+------+-------+------+---------+------+
4 rows in set (0.00 sec)

2. Query to insert the following Data into the table Student.

mysql> INSERT INTO STU VALUES(1, 'AMAN', 67, 56, 45, 72, 87);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO STU VALUES(2, 'HEENA', 81, 78, 65, 82, 97);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO STU VALUES(3, 'MUKESH', 59, 69, 58, 70, 55);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO STU VALUES(4, 'MUKESH', 69, 75, 88, 79, 78);
Query OK, 1 row affected (0.00 sec)

3. Write a query to modify the NAME whose IT is 78 in the above Table

mysql> UPDATE STU SET NAME = 'NEETI' WHERE IT = 78;


Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT*FROM STU;

+---------+--------+------+-------+------+---------+------+
| Roll_No | Name | Eng | Hindi | Math | Science | IT |
+---------+--------+------+-------+------+---------+------+
| 1 | AMAN | 67 | 56 | 45 | 72 | 87 |
| 2 | HEENA | 81 | 78 | 65 | 82 | 97 |
| 3 | MUKESH | 59 | 69 | 58 | 70 | 55 |
| 4 | NEETI | 69 | 75 | 88 | 79 | 78 |
+---------+--------+------+-------+------+---------+------+
4 rows in set (0.00 sec)

4. Write a query to delete the table permanently.


mysql> DROP TABLE STU;
Query OK, 0 rows affected (0.03 sec)

mysql> DESC STU;


ERROR 1146 (42S02): Table 'abc.stu' doesn't exist

You might also like