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

Self Practice First Class

The document shows the steps of connecting to a MySQL database, creating a table, inserting data, updating data, and selecting data. Various SQL commands are used to manage the 'room007' database table including create, insert, update, select and delete.

Uploaded by

ankit05101998
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)
14 views

Self Practice First Class

The document shows the steps of connecting to a MySQL database, creating a table, inserting data, updating data, and selecting data. Various SQL commands are used to manage the 'room007' database table including create, insert, update, select and delete.

Uploaded by

ankit05101998
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
You are on page 1/ 4

Enter password: *********

Welcome to the MySQL monitor. Commands end with ; or \g.


Your MySQL connection id is 18
Server version: 8.0.31 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use database room007


ERROR 1049 (42000): Unknown database 'database'
mysql> use room007
Database changed
mysql> create table room007(Studentid int primary key,Studentname
varchar(40),Fathersname varchar(40),Hometown varchar(40),Grade varchar(10));
Query OK, 0 rows affected (0.10 sec)

mysql> desc room007


-> desc room007;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'desc
room007' at line 2
mysql> desc room007;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| Studentid | int | NO | PRI | NULL | |
| Studentname | varchar(40) | YES | | NULL | |
| Fathersname | varchar(40) | YES | | NULL | |
| Hometown | varchar(40) | YES | | NULL | |
| Grade | varchar(10) | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
5 rows in set (0.04 sec)

mysql> insert into room007 value(101,"Ankit singh",'Shiv Balak


singh','Renukoot','A');
Query OK, 1 row affected (0.02 sec)

mysql> select * from Room007


-> select * from Room007;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'select *
from Room007' at line 2
mysql> select * from Room007;
+-----------+-------------+------------------+----------+-------+
| Studentid | Studentname | Fathersname | Hometown | Grade |
+-----------+-------------+------------------+----------+-------+
| 101 | Ankit singh | Shiv Balak singh | Renukoot | A |
+-----------+-------------+------------------+----------+-------+
1 row in set (0.00 sec)

mysql> insert into room007 value(102,"Mrityunjay Yadav",'Bheem


Yadav','Renukoot','A');
Query OK, 1 row affected (0.00 sec)
mysql> insert into room007 value(102,"Bhupender",'Mahan','Gurgaon','A');
ERROR 1062 (23000): Duplicate entry '102' for key 'room007.PRIMARY'
mysql> insert into room007 value(103,"Bhupender",'Mahan','Gurgaon','A');
Query OK, 1 row affected (0.01 sec)

mysql> insert into room007 value(104,"Kumar",'Baap','^Bihar','A');


Query OK, 1 row affected (0.01 sec)

mysql> insert into room007 value(105,"Ankit Pandey",'A.k.Pandey','Prayagraj','B');


Query OK, 1 row affected (0.00 sec)

mysql> select * from room007;


+-----------+------------------+------------------+-----------+-------+
| Studentid | Studentname | Fathersname | Hometown | Grade |
+-----------+------------------+------------------+-----------+-------+
| 101 | Ankit singh | Shiv Balak singh | Renukoot | A |
| 102 | Mrityunjay Yadav | Bheem Yadav | Renukoot | A |
| 103 | Bhupender | Mahan | Gurgaon | A |
| 104 | Kumar | Baap | ☻ihar | A |
| 105 | Ankit Pandey | A.k.Pandey | Prayagraj | B |
+-----------+------------------+------------------+-----------+-------+
5 rows in set (0.00 sec)

mysql> insert into room007 value(105,"Shayam Shacu",'R.k Shahu','Rachi','B');


ERROR 1062 (23000): Duplicate entry '105' for key 'room007.PRIMARY'
mysql> insert into room007 value(106,"Shayam Shacu",'R.k Shahu','Rachi','B');
Query OK, 1 row affected (0.00 sec)

mysql> insert into room007 value(106,"Santosh singh",'P.k singh','Delhi','B');


ERROR 1062 (23000): Duplicate entry '106' for key 'room007.PRIMARY'
mysql> insert into room007 value(107,"Santosh singh",'P.k singh','Delhi','B')
-> insert into room007 value(107,"Santosh singh",'P.k singh','Delhi','B');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'insert
into room007 value(107,"Santosh singh",'P.k singh','Delhi','B')' at line 2
mysql> insert into room007 value(107,"Santosh singh",'P.k singh','Delhi','B');
Query OK, 1 row affected (0.00 sec)

mysql> insert into room007 value(108,"Sonu singh",'N.Y singh','Delhi','C');


Query OK, 1 row affected (0.00 sec)

mysql> insert into room007 value(109,"Surya Ray",'P.F Ray','Lucknow','A');


Query OK, 1 row affected (0.01 sec)

mysql> select * from room007;


+-----------+------------------+------------------+-----------+-------+
| Studentid | Studentname | Fathersname | Hometown | Grade |
+-----------+------------------+------------------+-----------+-------+
| 101 | Ankit singh | Shiv Balak singh | Renukoot | A |
| 102 | Mrityunjay Yadav | Bheem Yadav | Renukoot | A |
| 103 | Bhupender | Mahan | Gurgaon | A |
| 104 | Kumar | Baap | ☻ihar | A |
| 105 | Ankit Pandey | A.k.Pandey | Prayagraj | B |
| 106 | Shayam Shacu | R.k Shahu | Rachi | B |
| 107 | Santosh singh | P.k singh | Delhi | B |
| 108 | Sonu singh | N.Y singh | Delhi | C |
| 109 | Surya Ray | P.F Ray | Lucknow | A |
+-----------+------------------+------------------+-----------+-------+
9 rows in set (0.00 sec)
mysql> use database room007
ERROR 1049 (42000): Unknown database 'database'
mysql> desc room007
-> ;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| Studentid | int | NO | PRI | NULL | |
| Studentname | varchar(40) | YES | | NULL | |
| Fathersname | varchar(40) | YES | | NULL | |
| Hometown | varchar(40) | YES | | NULL | |
| Grade | varchar(10) | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> install pip


-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'pip' at
line 1
mysql> install pip;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'pip' at
line 1
mysql> install 'pip'
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ''pip''
at line 1
mysql> install 'pip';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ''pip''
at line 1
mysql> install data base;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'data
base' at line 1
mysql> insert into room007 value(109,"Surya Ray",'P.F Ray','Lucknow','A');
ERROR 1062 (23000): Duplicate entry '109' for key 'room007.PRIMARY'
mysql> select * from room007;
+-----------+------------------+------------------+-----------+-------+
| Studentid | Studentname | Fathersname | Hometown | Grade |
+-----------+------------------+------------------+-----------+-------+
| 101 | Ankit singh | Shiv Balak singh | Renukoot | A |
| 102 | Mrityunjay Yadav | Bheem Yadav | Renukoot | A |
| 103 | Bhupender | Mahan | Gurgaon | A |
| 104 | Kumar | Baap | ☻ihar | A |
| 105 | Ankit Pandey | A.k.Pandey | Prayagraj | B |
| 106 | Shayam Shacu | R.k Shahu | Rachi | B |
| 107 | Santosh singh | P.k singh | Delhi | B |
| 108 | Sonu singh | N.Y singh | Delhi | C |
| 109 | Surya Ray | P.F Ray | Lucknow | A |
+-----------+------------------+------------------+-----------+-------+
9 rows in set (0.00 sec)

mysql> insert into room007 value(110,"Surya Ray",'P.F Ray','Lucknow','A');


Query OK, 1 row affected (0.01 sec)
mysql> select * from room007;
+-----------+------------------+------------------+-----------+-------+
| Studentid | Studentname | Fathersname | Hometown | Grade |
+-----------+------------------+------------------+-----------+-------+
| 101 | Ankit singh | Shiv Balak singh | Renukoot | A |
| 102 | Mrityunjay Yadav | Bheem Yadav | Renukoot | A |
| 103 | Bhupender | Mahan | Gurgaon | A |
| 104 | Kumar | Baap | ☻ihar | A |
| 105 | Ankit Pandey | A.k.Pandey | Prayagraj | B |
| 106 | Shayam Shacu | R.k Shahu | Rachi | B |
| 107 | Santosh singh | P.k singh | Delhi | B |
| 108 | Sonu singh | N.Y singh | Delhi | C |
| 109 | Surya Ray | P.F Ray | Lucknow | A |
| 110 | Surya Ray | P.F Ray | Lucknow | A |
+-----------+------------------+------------------+-----------+-------+
10 rows in set (0.00 sec)

mysql> update into room007;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'into
room007' at line 1
mysql> update room007;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
mysql> update into room007 value(110,'Neeraj','Bhagat Singh','Haryana','A')
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'into
room007 value(110,'Neeraj','Bhagat Singh','Haryana','A')' at line 1
mysql>

You might also like