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

Assignment 3-DML

The document demonstrates various data manipulation language (DML) commands in MySQL including creating a database and table, inserting, updating, deleting and selecting data, and dropping the table.

Uploaded by

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

Assignment 3-DML

The document demonstrates various data manipulation language (DML) commands in MySQL including creating a database and table, inserting, updating, deleting and selecting data, and dropping the table.

Uploaded by

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

Assignment 3: DML

Enter password: ****

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

Your MySQL connection id is 9

Server version: 8.0.33 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> create database DML;

Query OK, 1 row affected (0.02 sec)

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| college |

| database_name |

| ddl |

| dept |

| dml |

| information_schema |

| mysql |

| performance_schema |

| sys |
+--------------------+

9 rows in set (0.06 sec)

mysql> use dml;

Database changed

mysql> create table students(roll_no int, Name varchar(10),phone_No varchar(10));

Query OK, 0 rows affected (0.04 sec)

mysql> desc students;

+----------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+----------+-------------+------+-----+---------+-------+

| roll_no | int | YES | | NULL | |

| Name | varchar(10) | YES | | NULL | |

| phone_No | varchar(10) | YES | | NULL | |

+----------+-------------+------+-----+---------+-------+

3 rows in set (0.02 sec)

mysql> insert into students values(101,'pooja','99776534567');

ERROR 1406 (22001): Data too long for column 'phone_No' at row 1

mysql> insert into students values(101,'pooja','9977653456');

Query OK, 1 row affected (0.01 sec)

mysql> insert into students values(102,'sachin','997893456');

Query OK, 1 row affected (0.01 sec)

mysql> insert into students values(103,'Tejal','997855686');

Query OK, 1 row affected (0.00 sec)

mysql> select * from students;

+---------+--------+------------+
| roll_no | Name | phone_No |

+---------+--------+------------+

| 101 | pooja | 9977653456 |

| 102 | sachin | 997893456 |

| 103 | Tejal | 997855686 |

+---------+--------+------------+

3 rows in set (0.00 sec)

mysql> select Name from students;

+--------+

| Name |

+--------+

| pooja |

| sachin |

| Tejal |

+--------+

3 rows in set (0.00 sec)

mysql> update students set Name='priya' where roll_no=102;

Query OK, 1 row affected (0.01 sec)

Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from students;

+---------+-------+------------+

| roll_no | Name | phone_No |

+---------+-------+------------+

| 101 | pooja | 9977653456 |

| 102 | priya | 997893456 |

| 103 | Tejal | 997855686 |

+---------+-------+------------+

3 rows in set (0.00 sec)


mysql> delete from students where roll_no=103;

Query OK, 1 row affected (0.01 sec)

mysql> select * from students;

+---------+-------+------------+

| roll_no | Name | phone_No |

+---------+-------+------------+

| 101 | pooja | 9977653456 |

| 102 | priya | 997893456 |

+---------+-------+------------+

2 rows in set (0.00 sec)

mysql> truncate table students;

Query OK, 0 rows affected (0.03 sec)

mysql> select * from students;

Empty set (0.00 sec)

mysql> drop table students;

Query OK, 0 rows affected (0.02 sec)

You might also like