0% found this document useful (0 votes)
4 views2 pages

MySQL School Database Management

Uploaded by

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

MySQL School Database Management

Uploaded by

tomitnayak518
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

mysql> CREATE DATABASE SCHOOLDB;

Query OK, 1 row affected (0.93 sec)

mysql> USE SCHOOLDB;


Database changed
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| schooldb |
| sys |
+--------------------+
5 rows in set (0.82 sec)

mysql> CREATE TABLE STUDENTS ( ADMNO INT PRIMARY KEY,NAME VARCHAR(30), CLASS INT
NOT NULL , MARKS INT );
Query OK, 0 rows affected (1.32 sec)

mysql> DESC STUDENTS;


+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| ADMNO | int | NO | PRI | NULL | |
| NAME | varchar(30) | YES | | NULL | |
| CLASS | int | NO | | NULL | |
| MARKS | int | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
4 rows in set (0.07 sec)

mysql> SHOW TABLES;


+--------------------+
| Tables_in_schooldb |
+--------------------+
| students |
+--------------------+
1 row in set (0.10 sec)

mysql> ALTER TABLE STUDENTS ADD EMAIL VARCHAR(50);


Query OK, 0 rows affected (2.56 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> ALTER TABLE STUDENTS DROP EMAIL;


Query OK, 0 rows affected (0.30 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> ALTER TABLE STUDENTS DROP PRIMARY KEY;


Query OK, 0 rows affected (0.47 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> INSERT INTO STUDENTS VALUES


-> (101,'Riya',12,85),
-> (102,'Aman',12,78),
-> (103,'Kiran',11,92);
Query OK, 3 rows affected (0.17 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> UPDATE STUDENTS SET MARKS = MARKS*1.10 WHERE NAME ='Kiran';
Query OK, 1 row affected (0.12 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> UPDATE STUDENTS SET MARKS =MARKS +5 WHERE MARKS > 80;
Query OK, 2 rows affected (0.10 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> DELETE FROM STUDENTS WHERE NAME = 'Aman';


Query OK, 1 row affected (0.04 sec)

mysql> DELETE FROM STUDENTS WHERE NAME = 'Kiran' AND CLASS = 11;
Query OK, 1 row affected (0.03 sec)

mysql> DROP TABLE STUDENTS;


Query OK, 0 rows affected (0.06 sec)

mysql> DROP DATABASE SCHOOLDB;


Query OK, 0 rows affected (0.22 sec)

You might also like