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.
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 ratings0% 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.
-> 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
-> 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
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>