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

Ass 3

The document shows the steps taken to connect to a MySQL database, select a database, create and populate a table, update data in the table, and view the table contents. There are some syntax errors encountered and corrected along the way.

Uploaded by

RIYA SUDRIK
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Ass 3

The document shows the steps taken to connect to a MySQL database, select a database, create and populate a table, update data in the table, and view the table contents. There are some syntax errors encountered and corrected along the way.

Uploaded by

RIYA SUDRIK
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Enter password: *****

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


Your MySQL connection id is 19
Server version: 8.0.34 MySQL Community Server - GPL

Copyright (c) 2000, 2023, 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> show databses;


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
'databses' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| sys |
| world |
+--------------------+
6 rows in set (0.02 sec)

mysql> create table industry(srno int, part_name varchar(20),model_no int, supplier


varchar(20), quantity int);
ERROR 1046 (3D000): No database selected
mysql> use mysql;
Database changed
mysql> create table industry(srno int, part_name varchar(20),model_no int, supplier
varchar(20), quantity int);
Query OK, 0 rows affected (0.03 sec)

mysql> insert into industry (srno,part_name,model_no,supplier,quantity)


-> values(1,"engine",335,"pune",90)
-> values(2,"brakes",335,"bombay",35)
-> values(3,"car oil",236,"kolkata",98)
-> values(4,"tyres",789,"chennai",168)
-> values(5,"seat cover",345,"ahemdabad",35)
-> values(6,"a/c",789,"allahabad",20);
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
'values(2,"brakes",335,"bombay",35)
values(3,"car oil",236,"kolkata",98)
values(4' at line 3
mysql> insert into industry (srno,part_name,model_no,supplier,quantity)
-> values(1,"engine",335,"pune",90);
Query OK, 1 row affected (0.01 sec)

mysql> insert into industry (srno,part_name,model_no,supplier,quantity)


-> values(6,"a/c",789,"allahabad",20);
Query OK, 1 row affected (0.01 sec)
mysql> insert into industry (srno,part_name,model_no,supplier,quantity)
-> values(2,"brakes",335,"bombay",35);
Query OK, 1 row affected (0.01 sec)

mysql> insert into industry (srno,part_name,model_no,supplier,quantity)


-> values(3,"car oil",236,"kolkata",98);
Query OK, 1 row affected (0.00 sec)

mysql> insert into industry (srno,part_name,model_no,supplier,quantity)


-> values(5,"seat cover",345,"ahemdabad",35);
Query OK, 1 row affected (0.01 sec)

mysql> insert into industry (srno,part_name,model_no,supplier,quantity)


-> values(4,"tyres",789,"chennai",168);
Query OK, 1 row affected (0.01 sec)

mysql> show tables;


+------------------------------------------------------+
| Tables_in_mysql |
+------------------------------------------------------+
| columns_priv |
| component |
| db |
| default_roles |
| engine_cost |
| func |
| general_log |
| global_grants |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| industry |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| password_history |
| plugin |
| procs_priv |
| proxies_priv |
| replication_asynchronous_connection_failover |
| replication_asynchronous_connection_failover_managed |
| replication_group_configuration_version |
| replication_group_member_actions |
| role_edges |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+------------------------------------------------------+
39 rows in set (0.02 sec)

mysql> show industry;


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
'industry' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| sys |
| world |
+--------------------+
6 rows in set (0.00 sec)

mysql> use mysql;


Database changed
mysql> show tables from mysql;
+------------------------------------------------------+
| Tables_in_mysql |
+------------------------------------------------------+
| columns_priv |
| component |
| db |
| default_roles |
| engine_cost |
| func |
| general_log |
| global_grants |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| industry |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| password_history |
| plugin |
| procs_priv |
| proxies_priv |
| replication_asynchronous_connection_failover |
| replication_asynchronous_connection_failover_managed |
| replication_group_configuration_version |
| replication_group_member_actions |
| role_edges |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+------------------------------------------------------+
39 rows in set (0.00 sec)

mysql> desc industry;


+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| srno | int | YES | | NULL | |
| part_name | varchar(20) | YES | | NULL | |
| model_no | int | YES | | NULL | |
| supplier | varchar(20) | YES | | NULL | |
| quantity | int | YES | | NULL | |
+-----------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

mysql> update industry set quantity="33" where srno="1";


Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> show table industry;


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
'industry' at line 1
mysql> show industry;
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
'industry' at line 1
mysql> SELECT * FROM industry;
+------+------------+----------+-----------+----------+
| srno | part_name | model_no | supplier | quantity |
+------+------------+----------+-----------+----------+
| 1 | engine | 335 | pune | 33 |
| 6 | a/c | 789 | allahabad | 20 |
| 2 | brakes | 335 | bombay | 35 |
| 3 | car oil | 236 | kolkata | 98 |
| 5 | seat cover | 345 | ahemdabad | 35 |
| 4 | tyres | 789 | chennai | 168 |
+------+------------+----------+-----------+----------+
6 rows in set (0.00 sec)

mysql> update industry set supplier="hyderabad" where srno="5";


Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> SELECT * FROM industry;


+------+------------+----------+-----------+----------+
| srno | part_name | model_no | supplier | quantity |
+------+------------+----------+-----------+----------+
| 1 | engine | 335 | pune | 33 |
| 6 | a/c | 789 | allahabad | 20 |
| 2 | brakes | 335 | bombay | 35 |
| 3 | car oil | 236 | kolkata | 98 |
| 5 | seat cover | 345 | hyderabad | 35 |
| 4 | tyres | 789 | chennai | 168 |
+------+------------+----------+-----------+----------+
6 rows in set (0.00 sec)

mysql> delete from industry where srno=


-> "6";
Query OK, 1 row affected (0.01 sec)

mysql> SELECT * FROM industry;


+------+------------+----------+-----------+----------+
| srno | part_name | model_no | supplier | quantity |
+------+------------+----------+-----------+----------+
| 1 | engine | 335 | pune | 33 |
| 2 | brakes | 335 | bombay | 35 |
| 3 | car oil | 236 | kolkata | 98 |
| 5 | seat cover | 345 | hyderabad | 35 |
| 4 | tyres | 789 | chennai | 168 |
+------+------------+----------+-----------+----------+
5 rows in set (0.00 sec)

mysql> delete from industry where srno="4";


Query OK, 1 row affected (0.01 sec)

mysql> SELECT * FROM industry;


+------+------------+----------+-----------+----------+
| srno | part_name | model_no | supplier | quantity |
+------+------------+----------+-----------+----------+
| 1 | engine | 335 | pune | 33 |
| 2 | brakes | 335 | bombay | 35 |
| 3 | car oil | 236 | kolkata | 98 |
| 5 | seat cover | 345 | hyderabad | 35 |
+------+------------+----------+-----------+----------+
4 rows in set (0.00 sec)

mysql>

You might also like