0% found this document useful (0 votes)
12 views18 pages

Practical 2

The document details a MySQL session where a user connects to a MySQL database and performs various operations including showing databases, using a specific database, and inserting data into tables for categories, customers, products, orders, and order details. It includes commands and their outputs, demonstrating the structure of the tables and the data being manipulated. The session concludes with the insertion of order details into the database.

Uploaded by

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

Practical 2

The document details a MySQL session where a user connects to a MySQL database and performs various operations including showing databases, using a specific database, and inserting data into tables for categories, customers, products, orders, and order details. It includes commands and their outputs, demonstrating the structure of the tables and the data being manipulated. The session concludes with the insertion of order details into the database.

Uploaded by

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

Last login: Fri Apr 25 13:08:50 on ttys005

razashaikh@Razas-MacBook-Air ~ % /usr/local/mysql/bin/mysql -u root -p


Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 9.2.0 MySQL Community Server - GPL

Copyright (c) 2000, 2025, 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 databases;


+--------------------+
| Database |
+--------------------+
| animal |
| information_schema |
| mysql |
| performance_schema |
| SaharaReadymade |
+--------------------+
5 rows in set (0.00 sec)

mysql> use saharareadymade;


Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------------------+
| Tables_in_saharareadymade |
+---------------------------+
| Categories |
| Customers |
| Employees |
| OrderDetails |
| Orders |
| Products |
+---------------------------+
6 rows in set (0.01 sec)

mysql> INSERT INTO Categories (category_name, description) VALUES


-> ('Men''s Clothing', 'Clothing items for men'),
-> ('Women''s Clothing', 'Clothing items for women'),
-> ('Kids'' Clothing', 'Clothing items for children'),
-> ('Accessories', 'Fashion accessories');
Query OK, 4 rows affected (0.02 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> select * from categories;
+-------------+------------------+-----------------------------+
| category_id | category_name | description |
+-------------+------------------+-----------------------------+
| 20 | Men's Clothing | Clothing items for men |
| 21 | Women's Clothing | Clothing items for women |
| 22 | Kids' Clothing | Clothing items for children |
| 23 | Accessories | Fashion accessories |
+-------------+------------------+-----------------------------+
4 rows in set (0.00 sec)

mysql> desc customers;


+-------------------+--------------+------+-----+-------------------
+-------------------+
| Field | Type | Null | Key | Default |
Extra |
+-------------------+--------------+------+-----+-------------------
+-------------------+
| customer_id | int | NO | PRI | NULL |
auto_increment |
| first_name | varchar(50) | NO | | NULL |
|
| last_name | varchar(50) | NO | | NULL |
|
| phone_number | varchar(15) | YES | | NULL |
|
| email | varchar(100) | YES | UNI | NULL |
|
| address | text | YES | | NULL |
|
| registration_date | timestamp | YES | | CURRENT_TIMESTAMP |
DEFAULT_GENERATED |
+-------------------+--------------+------+-----+-------------------
+-------------------+
7 rows in set (0.02 sec)

mysql> INSERT INTO Customers (first_name, last_name, phone_number, email,


address) VALUES
-> ('Rahul', 'Sharma', '9876543210', 'rahul@[Link]', 'Mumbai,
Maharashtra'),
-> ('Priya', 'Patel', '8765432109', 'priya@[Link]', 'Delhi,
Delhi'),
-> ('Amit', 'Singh', '7654321098', 'amit@[Link]', 'Bangalore,
Karnataka'),
-> ('Neha', 'Gupta', '6543210987', 'neha@[Link]', 'Chennai,
Tamil Nadu'),
-> ('Karan', 'Mehta', '9123456780', '[Link]@[Link]', 'Pune,
Maharashtra'),
-> ('Anjali', 'Reddy', '9012345678', '[Link]@[Link]',
'Hyderabad, Telangana'),
-> ('Vikram', 'Verma', '8899776655', '[Link]@[Link]',
'Jaipur, Rajasthan'),
-> ('Sneha', 'Desai', '9988776655', '[Link]@[Link]',
'Ahmedabad, Gujarat'),
-> ('Rohit', 'Nair', '9090909090', '[Link]@[Link]', 'Kochi,
Kerala'),
-> ('Tanya', 'Kapoor', '8888777766', '[Link]@[Link]',
'Lucknow, Uttar Pradesh');
Query OK, 10 rows affected (0.02 sec)
Records: 10 Duplicates: 0 Warnings: 0

mysql> select * from customers;


+-------------+------------+-----------+--------------
+--------------------------+------------------------
+---------------------+
| customer_id | first_name | last_name | phone_number | email
| address | registration_date |
+-------------+------------+-----------+--------------
+--------------------------+------------------------
+---------------------+
| 11 | Rahul | Sharma | 9876543210 | rahul@[Link]
| Mumbai, Maharashtra | 2025-04-25 13:18:49 |
| 12 | Priya | Patel | 8765432109 | priya@[Link]
| Delhi, Delhi | 2025-04-25 13:18:49 |
| 13 | Amit | Singh | 7654321098 | amit@[Link]
| Bangalore, Karnataka | 2025-04-25 13:18:49 |
| 14 | Neha | Gupta | 6543210987 | neha@[Link]
| Chennai, Tamil Nadu | 2025-04-25 13:18:49 |
| 15 | Karan | Mehta | 9123456780 |
[Link]@[Link] | Pune, Maharashtra | 2025-04-25 13:18:49 |
| 16 | Anjali | Reddy | 9012345678 |
[Link]@[Link] | Hyderabad, Telangana | 2025-04-25 13:18:49 |
| 17 | Vikram | Verma | 8899776655 |
[Link]@[Link] | Jaipur, Rajasthan | 2025-04-25 13:18:49 |
| 18 | Sneha | Desai | 9988776655 |
[Link]@[Link] | Ahmedabad, Gujarat | 2025-04-25 13:18:49 |
| 19 | Rohit | Nair | 9090909090 |
[Link]@[Link] | Kochi, Kerala | 2025-04-25 13:18:49 |
| 20 | Tanya | Kapoor | 8888777766 |
[Link]@[Link] | Lucknow, Uttar Pradesh | 2025-04-25 13:18:49 |
+-------------+------------+-----------+--------------
+--------------------------+------------------------
+---------------------+
10 rows in set (0.00 sec)

mysql> desc products;


+----------------+---------------+------+-----+---------+----------------
+
| Field | Type | Null | Key | Default | Extra
|
+----------------+---------------+------+-----+---------+----------------
+
| product_id | int | NO | PRI | NULL | auto_increment
|
| product_name | varchar(100) | NO | | NULL |
|
| category_id | int | YES | MUL | NULL |
|
| price | decimal(10,2) | NO | | NULL |
|
| stock_quantity | int | NO | | NULL |
|
| size | varchar(10) | YES | | NULL |
|
| color | varchar(30) | YES | | NULL |
|
+----------------+---------------+------+-----+---------+----------------
+
7 rows in set (0.01 sec)

mysql> select * from categories;


+-------------+------------------+-----------------------------+
| category_id | category_name | description |
+-------------+------------------+-----------------------------+
| 20 | Men's Clothing | Clothing items for men |
| 21 | Women's Clothing | Clothing items for women |
| 22 | Kids' Clothing | Clothing items for children |
| 23 | Accessories | Fashion accessories |
+-------------+------------------+-----------------------------+
4 rows in set (0.00 sec)

mysql> INSERT INTO Products (product_name, category_id, price,


stock_quantity) VALUES
-> ('Men''s T-Shirt', 20, 599.99, 50),
-> ('Women''s Dress', 21, 1299.99, 30),
-> ('Kids'' Jeans', 22, 499.99, 25),
-> ('Scarf', 23, 299.99, 40),
-> ('Men''s Jeans', 20, 899.99, 35),
-> ('Women''s Top', 21, 699.99, 45),
-> ('Kids'' T-Shirt', 22, 399.99, 60),
-> ('Handbag', 23, 1499.99, 20),
-> ('Men''s Jacket', 20, 1599.99, 15),
-> ('Women''s jacket', 21, 899.99, 28);
Query OK, 10 rows affected (0.01 sec)
Records: 10 Duplicates: 0 Warnings: 0

mysql> select * from products;


+------------+----------------+-------------+---------+----------------
+------+-------+
| product_id | product_name | category_id | price | stock_quantity |
size | color |
+------------+----------------+-------------+---------+----------------
+------+-------+
| 35 | Men's T-Shirt | 20 | 599.99 | 50 |
NULL | NULL |
| 36 | Women's Dress | 21 | 1299.99 | 30 |
NULL | NULL |
| 37 | Kids' Jeans | 22 | 499.99 | 25 |
NULL | NULL |
| 38 | Scarf | 23 | 299.99 | 40 |
NULL | NULL |
| 39 | Men's Jeans | 20 | 899.99 | 35 |
NULL | NULL |
| 40 | Women's Top | 21 | 699.99 | 45 |
NULL | NULL |
| 41 | Kids' T-Shirt | 22 | 399.99 | 60 |
NULL | NULL |
| 42 | Handbag | 23 | 1499.99 | 20 |
NULL | NULL |
| 43 | Men's Jacket | 20 | 1599.99 | 15 |
NULL | NULL |
| 44 | Women's jacket | 21 | 899.99 | 28 |
NULL | NULL |
+------------+----------------+-------------+---------+----------------
+------+-------+
10 rows in set (0.00 sec)

mysql> desc orders;


+----------------+---------------+------+-----+-------------------
+-------------------+
| Field | Type | Null | Key | Default | Extra
|
+----------------+---------------+------+-----+-------------------
+-------------------+
| order_id | int | NO | PRI | NULL |
auto_increment |
| customer_id | int | YES | MUL | NULL |
|
| order_date | timestamp | YES | | CURRENT_TIMESTAMP |
DEFAULT_GENERATED |
| total_amount | decimal(10,2) | YES | | NULL |
|
| status | varchar(10) | YES | | NULL |
|
| payment_status | varchar(20) | YES | | Pending |
|
+----------------+---------------+------+-----+-------------------
+-------------------+
6 rows in set (0.02 sec)

+-------------+------------+-----------+
| customer_id | first_name | last_name |
+-------------+------------+-----------+
| 11 | Rahul | Sharma |
| 12 | Priya | Patel |
| 13 | Amit | Singh |
| 14 | Neha | Gupta |
| 15 | Karan | Mehta |
| 16 | Anjali | Reddy |
| 17 | Vikram | Verma |
| 18 | Sneha | Desai |
| 19 | Rohit | Nair |
| 20 | Tanya | Kapoor |
+-------------+------------+-----------+
10 rows in set (0.01 sec)
mysql> INSERT INTO orders (customer_id, order_date, total_amount, status,
payment_status) VALUES
-> (11, NOW(), 2499.97, 'Confirmed', 'Paid'),
-> (12, NOW(), 1299.99, 'Shipped', 'Paid'),
-> (13, NOW(), 999.98, 'Processing', 'Pending'),
-> (14, NOW(), 299.99, 'Delivered', 'Paid'),
-> (15, NOW(), 899.99, 'Cancelled', 'Refunded'),
-> (16, NOW(), 1799.98, 'Shipped', 'Paid'),
-> (17, NOW(), 1499.99, 'Confirmed', 'Pending'),
-> (18, NOW(), 399.99, 'Processing', 'Pending'),
-> (19, NOW(), 1599.99, 'Delivered', 'Paid'),
-> (20, NOW(), 899.99, 'Confirmed', 'Paid');
Query OK, 10 rows affected (0.00 sec)
Records: 10 Duplicates: 0 Warnings: 0

mysql> select * from orders;


+----------+-------------+---------------------+--------------
+------------+----------------+
| order_id | customer_id | order_date | total_amount | status
| payment_status |
+----------+-------------+---------------------+--------------
+------------+----------------+
| 38 | 11 | 2025-04-25 13:54:47 | 2499.97 | Confirmed
| Paid |
| 39 | 12 | 2025-04-25 13:54:47 | 1299.99 | Shipped
| Paid |
| 40 | 13 | 2025-04-25 13:54:47 | 999.98 |
Processing | Pending |
| 41 | 14 | 2025-04-25 13:54:47 | 299.99 | Delivered
| Paid |
| 42 | 15 | 2025-04-25 13:54:47 | 899.99 | Cancelled
| Refunded |
| 43 | 16 | 2025-04-25 13:54:47 | 1799.98 | Shipped
| Paid |
| 44 | 17 | 2025-04-25 13:54:47 | 1499.99 | Confirmed
| Pending |
| 45 | 18 | 2025-04-25 13:54:47 | 399.99 |
Processing | Pending |
| 46 | 19 | 2025-04-25 13:54:47 | 1599.99 | Delivered
| Paid |
| 47 | 20 | 2025-04-25 13:54:47 | 899.99 | Confirmed
| Paid |
+----------+-------------+---------------------+--------------
+------------+----------------+
10 rows in set (0.00 sec)

mysql> desc orderdetails;


+-----------------+---------------+------+-----+---------
+----------------+
| Field | Type | Null | Key | Default | Extra
|
+-----------------+---------------+------+-----+---------
+----------------+
| order_detail_id | int | NO | PRI | NULL | auto_increment
|
| order_id | int | YES | MUL | NULL |
|
| product_id | int | YES | MUL | NULL |
|
| quantity | int | NO | | NULL |
|
| price_at_time | decimal(10,2) | YES | | NULL |
|
+-----------------+---------------+------+-----+---------
+----------------+
5 rows in set (0.00 sec)

mysql> INSERT INTO orderdetails (order_id, product_id, quantity,


price_at_time) VALUES
-> (38, 35, 2, 499.99),
-> (39, 36, 1, 899.99),
-> (40, 37, 3, 399.99),
-> (41, 38, 1, 799.99),
-> (42, 39, 2, 699.99),
-> (43, 40, 1, 1299.99),
-> (44, 41, 1, 1599.99),
-> (45, 42, 2, 899.99),
-> (46, 43, 1, 1499.99),
-> (47, 44, 1, 999.99);
Query OK, 10 rows affected (0.01 sec)
Records: 10 Duplicates: 0 Warnings: 0

mysql> select * from orderdetails;


+-----------------+----------+------------+----------+---------------+
| order_detail_id | order_id | product_id | quantity | price_at_time |
+-----------------+----------+------------+----------+---------------+
| 48 | 38 | 35 | 2 | 499.99 |
| 49 | 39 | 36 | 1 | 899.99 |
| 50 | 40 | 37 | 3 | 399.99 |
| 51 | 41 | 38 | 1 | 799.99 |
| 52 | 42 | 39 | 2 | 699.99 |
| 53 | 43 | 40 | 1 | 1299.99 |
| 54 | 44 | 41 | 1 | 1599.99 |
| 55 | 45 | 42 | 2 | 899.99 |
| 56 | 46 | 43 | 1 | 1499.99 |
| 57 | 47 | 44 | 1 | 999.99 |
+-----------------+----------+------------+----------+---------------+
10 rows in set (0.01 sec)

mysql> mysql> UPDATE Categories


-> SET description = 'Men''s fashion clothing including shirts, t-
shirts, jeans'
-> WHERE category_id = 20;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Categories
-> SET description = 'Women''s fashion clothing including dresses,
tops, skirts'
-> WHERE category_id = 21;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Categories
-> SET description = 'Children''s clothing for ages 0-12'
-> WHERE category_id = 22;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Categories
-> SET description = 'Accessories including bags, scarves, jewelry'
-> WHERE category_id = 23;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Categories
-> SET category_name = 'Men''s Apparel'
-> WHERE category_id = 20;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from categories;


+-------------+------------------
+----------------------------------------------------------+
| category_id | category_name | description
|
+-------------+------------------
+----------------------------------------------------------+
| 20 | Men's Apparel | Men's fashion clothing including
shirts, t-shirts, jeans |
| 21 | Women's Clothing | Women's fashion clothing including
dresses, tops, skirts |
| 22 | Kids' Clothing | Children's clothing for ages 0-12
|
| 23 | Accessories | Accessories including bags, scarves,
jewelry |
+-------------+------------------
+----------------------------------------------------------+
4 rows in set (0.00 sec)

mysql> UPDATE Customers


-> SET phone_number = '9876543211'
-> WHERE customer_id = 11;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Customers
-> SET email = '[Link]@[Link]'
-> WHERE customer_id = 11;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Customers
-> SET address = 'Andheri East, Mumbai, Maharashtra'
-> WHERE customer_id = 11;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Customers
-> SET last_name = 'Sharma-Kapoor'
-> WHERE customer_id = 11;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Customers
-> SET phone_number = '8765432110'
-> WHERE customer_id = 12;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from customers;


+-------------+------------+---------------+--------------
+--------------------------+-----------------------------------
+---------------------+
| customer_id | first_name | last_name | phone_number | email
| address | registration_date |
+-------------+------------+---------------+--------------
+--------------------------+-----------------------------------
+---------------------+
| 11 | Rahul | Sharma-Kapoor | 9876543211 |
[Link]@[Link] | Andheri East, Mumbai, Maharashtra | 2025-04-25
13:18:49 |
| 12 | Priya | Patel | 8765432110 |
priya@[Link] | Delhi, Delhi | 2025-04-25
13:18:49 |
| 13 | Amit | Singh | 7654321098 |
amit@[Link] | Bangalore, Karnataka | 2025-04-25
13:18:49 |
| 14 | Neha | Gupta | 6543210987 |
neha@[Link] | Chennai, Tamil Nadu | 2025-04-25
13:18:49 |
| 15 | Karan | Mehta | 9123456780 |
[Link]@[Link] | Pune, Maharashtra | 2025-04-25
13:18:49 |
| 16 | Anjali | Reddy | 9012345678 |
[Link]@[Link] | Hyderabad, Telangana | 2025-04-25
13:18:49 |
| 17 | Vikram | Verma | 8899776655 |
[Link]@[Link] | Jaipur, Rajasthan | 2025-04-25
13:18:49 |
| 18 | Sneha | Desai | 9988776655 |
[Link]@[Link] | Ahmedabad, Gujarat | 2025-04-25
13:18:49 |
| 19 | Rohit | Nair | 9090909090 |
[Link]@[Link] | Kochi, Kerala | 2025-04-25
13:18:49 |
| 20 | Tanya | Kapoor | 8888777766 |
[Link]@[Link] | Lucknow, Uttar Pradesh | 2025-04-25
13:18:49 |
+-------------+------------+---------------+--------------
+--------------------------+-----------------------------------
+---------------------+
10 rows in set (0.00 sec)

mysql> UPDATE Products


-> SET price = 649.99
-> WHERE product_id = 35;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Products
-> SET stock_quantity = 60
-> WHERE product_id = 35;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Products
-> SET size = 'M'
-> WHERE product_id = 35;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Products
-> SET color = 'Blue'
-> WHERE product_id = 35;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Products
-> SET product_name = 'Men''s Cotton T-Shirt'
-> WHERE product_id = 35;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from products;


+------------+----------------------+-------------+---------
+----------------+------+-------+
| product_id | product_name | category_id | price |
stock_quantity | size | color |
+------------+----------------------+-------------+---------
+----------------+------+-------+
| 35 | Men's Cotton T-Shirt | 20 | 649.99 |
60 | M | Blue |
| 36 | Women's Dress | 21 | 1299.99 |
30 | NULL | NULL |
| 37 | Kids' Jeans | 22 | 499.99 |
25 | NULL | NULL |
| 38 | Scarf | 23 | 299.99 |
40 | NULL | NULL |
| 39 | Men's Jeans | 20 | 899.99 |
35 | NULL | NULL |
| 40 | Women's Top | 21 | 699.99 |
45 | NULL | NULL |
| 41 | Kids' T-Shirt | 22 | 399.99 |
60 | NULL | NULL |
| 42 | Handbag | 23 | 1499.99 |
20 | NULL | NULL |
| 43 | Men's Jacket | 20 | 1599.99 |
15 | NULL | NULL |
| 44 | Women's jacket | 21 | 899.99 |
28 | NULL | NULL |
+------------+----------------------+-------------+---------
+----------------+------+-------+
10 rows in set (0.00 sec)

mysql> UPDATE Orders


-> SET status = 'Delivered'
-> WHERE order_id = 38;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Orders
-> SET payment_status = 'Paid'
-> WHERE order_id = 44;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Orders
-> SET total_amount = 2599.97
-> WHERE order_id = 38;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE Orders
-> SET status = 'Processing'
-> WHERE order_id = 47;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql>
mysql> UPDATE Orders
-> SET payment_status = 'Refunded'
-> WHERE order_id = 42;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0

mysql> select * from orders;


+----------+-------------+---------------------+--------------
+------------+----------------+
| order_id | customer_id | order_date | total_amount | status
| payment_status |
+----------+-------------+---------------------+--------------
+------------+----------------+
| 38 | 11 | 2025-04-25 13:54:47 | 2599.97 | Delivered
| Paid |
| 39 | 12 | 2025-04-25 13:54:47 | 1299.99 | Shipped
| Paid |
| 40 | 13 | 2025-04-25 13:54:47 | 999.98 |
Processing | Pending |
| 41 | 14 | 2025-04-25 13:54:47 | 299.99 | Delivered
| Paid |
| 42 | 15 | 2025-04-25 13:54:47 | 899.99 | Cancelled
| Refunded |
| 43 | 16 | 2025-04-25 13:54:47 | 1799.98 | Shipped
| Paid |
| 44 | 17 | 2025-04-25 13:54:47 | 1499.99 | Confirmed
| Paid |
| 45 | 18 | 2025-04-25 13:54:47 | 399.99 |
Processing | Pending |
| 46 | 19 | 2025-04-25 13:54:47 | 1599.99 | Delivered
| Paid |
| 47 | 20 | 2025-04-25 13:54:47 | 899.99 |
Processing | Paid |
+----------+-------------+---------------------+--------------
+------------+----------------+
10 rows in set (0.00 sec)

mysql> UPDATE OrderDetails


-> SET quantity = 3
-> WHERE order_detail_id = 48;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE OrderDetails
-> SET price_at_time = 549.99
-> WHERE order_detail_id = 48;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE OrderDetails
-> SET quantity = 2
-> WHERE order_detail_id = 49;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE OrderDetails
-> SET price_at_time = 999.99
-> WHERE order_detail_id = 53;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql>
mysql> UPDATE OrderDetails
-> SET product_id = 36
-> WHERE order_detail_id = 55;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from orderdetails;


+-----------------+----------+------------+----------+---------------+
| order_detail_id | order_id | product_id | quantity | price_at_time |
+-----------------+----------+------------+----------+---------------+
| 48 | 38 | 35 | 3 | 549.99 |
| 49 | 39 | 36 | 2 | 899.99 |
| 50 | 40 | 37 | 3 | 399.99 |
| 51 | 41 | 38 | 1 | 799.99 |
| 52 | 42 | 39 | 2 | 699.99 |
| 53 | 43 | 40 | 1 | 999.99 |
| 54 | 44 | 41 | 1 | 1599.99 |
| 55 | 45 | 36 | 2 | 899.99 |
| 56 | 46 | 43 | 1 | 1499.99 |
| 57 | 47 | 44 | 1 | 999.99 |
+-----------------+----------+------------+----------+---------------+
10 rows in set (0.00 sec)

mysql> DELETE FROM OrderDetails WHERE product_id IN (SELECT product_id


FROM Products WHERE category_id = 23);
Query OK, 1 row affected (0.00 sec)

mysql> DELETE FROM Products WHERE category_id = 23;


Query OK, 2 rows affected (0.01 sec)

mysql> DELETE FROM Categories WHERE category_id = 23;


Query OK, 1 row affected (0.00 sec)

mysql> DELETE FROM OrderDetails WHERE order_id IN (SELECT order_id FROM


Orders WHERE customer_id = 20);
Query OK, 1 row affected (0.01 sec)

mysql> DELETE FROM Orders WHERE customer_id = 20;


Query OK, 1 row affected (0.00 sec)

mysql> DELETE FROM Customers WHERE customer_id = 20;


Query OK, 1 row affected (0.00 sec)

mysql>
mysql> DELETE FROM OrderDetails WHERE order_id IN (SELECT order_id FROM
Orders WHERE customer_id = 19);
Query OK, 1 row affected (0.00 sec)

mysql> DELETE FROM Orders WHERE customer_id = 19;


Query OK, 1 row affected (0.00 sec)

mysql> DELETE FROM Customers WHERE customer_id = 19;


Query OK, 1 row affected (0.00 sec)

mysql> DELETE FROM OrderDetails WHERE product_id = 44;


Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM Products WHERE product_id = 44;


Query OK, 1 row affected (0.00 sec)

mysql>
mysql> DELETE FROM OrderDetails WHERE product_id = 43;
Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM Products WHERE product_id = 43;


Query OK, 1 row affected (0.00 sec)

mysql>
mysql> DELETE FROM OrderDetails WHERE product_id = 42;
Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM Products WHERE product_id = 42;


Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> DELETE FROM OrderDetails WHERE product_id = 41;
Query OK, 1 row affected (0.01 sec)

mysql> DELETE FROM Products WHERE product_id = 41;


Query OK, 1 row affected (0.00 sec)

mysql>
mysql> DELETE FROM OrderDetails WHERE product_id = 40;
Query OK, 1 row affected (0.00 sec)

mysql> DELETE FROM Products WHERE product_id = 40;


Query OK, 1 row affected (0.00 sec)

mysql> DELETE FROM OrderDetails WHERE order_id = 47;


Query OK, 0 rows affected (0.01 sec)

mysql> DELETE FROM Orders WHERE order_id = 47;


Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> DELETE FROM OrderDetails WHERE order_id = 46;
Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM Orders WHERE order_id = 46;


Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> DELETE FROM OrderDetails WHERE order_id = 45;
Query OK, 1 row affected (0.00 sec)

mysql> DELETE FROM Orders WHERE order_id = 45;


Query OK, 1 row affected (0.00 sec)

mysql>
mysql> DELETE FROM OrderDetails WHERE order_id = 44;
Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM Orders WHERE order_id = 44;


Query OK, 1 row affected (0.00 sec)

mysql>
mysql> DELETE FROM OrderDetails WHERE order_id = 43;
Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM Orders WHERE order_id = 43;


Query OK, 1 row affected (0.00 sec)

mysql> DELETE FROM OrderDetails WHERE order_detail_id = 57;


Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM OrderDetails WHERE order_detail_id = 56;


Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM OrderDetails WHERE order_detail_id = 55;


Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM OrderDetails WHERE order_detail_id = 54;


Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM OrderDetails WHERE order_detail_id = 53;


Query OK, 0 rows affected (0.00 sec)

mysql> desc categories;


+---------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+----------------+
| category_id | int | NO | PRI | NULL | auto_increment |
| category_name | varchar(50) | NO | | NULL | |
| description | text | YES | | NULL | |
+---------------+-------------+------+-----+---------+----------------+
3 rows in set (0.02 sec)

mysql> desc products;


+----------------+---------------+------+-----+---------+----------------
+
| Field | Type | Null | Key | Default | Extra
|
+----------------+---------------+------+-----+---------+----------------
+
| product_id | int | NO | PRI | NULL | auto_increment
|
| product_name | varchar(100) | NO | | NULL |
|
| category_id | int | YES | MUL | NULL |
|
| price | decimal(10,2) | NO | | NULL |
|
| stock_quantity | int | NO | | NULL |
|
| size | varchar(10) | YES | | NULL |
|
| color | varchar(30) | YES | | NULL |
|
+----------------+---------------+------+-----+---------+----------------
+
7 rows in set (0.00 sec)

mysql> desc customers;


+-------------------+--------------+------+-----+-------------------
+-------------------+
| Field | Type | Null | Key | Default |
Extra |
+-------------------+--------------+------+-----+-------------------
+-------------------+
| customer_id | int | NO | PRI | NULL |
auto_increment |
| first_name | varchar(50) | NO | | NULL |
|
| last_name | varchar(50) | NO | | NULL |
|
| phone_number | varchar(15) | YES | | NULL |
|
| email | varchar(100) | YES | UNI | NULL |
|
| address | text | YES | | NULL |
|
| registration_date | timestamp | YES | | CURRENT_TIMESTAMP |
DEFAULT_GENERATED |
+-------------------+--------------+------+-----+-------------------
+-------------------+
7 rows in set (0.00 sec)

mysql> select * from products;


+------------+----------------------+-------------+---------
+----------------+------+-------+
| product_id | product_name | category_id | price |
stock_quantity | size | color |
+------------+----------------------+-------------+---------
+----------------+------+-------+
| 35 | Men's Cotton T-Shirt | 20 | 649.99 |
60 | M | Blue |
| 36 | Women's Dress | 21 | 1299.99 |
30 | NULL | NULL |
| 37 | Kids' Jeans | 22 | 499.99 |
25 | NULL | NULL |
| 39 | Men's Jeans | 20 | 899.99 |
35 | NULL | NULL |
+------------+----------------------+-------------+---------
+----------------+------+-------+
4 rows in set (0.00 sec)

mysql> select * from customers;


+-------------+------------+---------------+--------------
+--------------------------+-----------------------------------
+---------------------+
| customer_id | first_name | last_name | phone_number | email
| address | registration_date |
+-------------+------------+---------------+--------------
+--------------------------+-----------------------------------
+---------------------+
| 11 | Rahul | Sharma-Kapoor | 9876543211 |
[Link]@[Link] | Andheri East, Mumbai, Maharashtra | 2025-04-25
13:18:49 |
| 12 | Priya | Patel | 8765432110 |
priya@[Link] | Delhi, Delhi | 2025-04-25
13:18:49 |
| 13 | Amit | Singh | 7654321098 |
amit@[Link] | Bangalore, Karnataka | 2025-04-25
13:18:49 |
| 14 | Neha | Gupta | 6543210987 |
neha@[Link] | Chennai, Tamil Nadu | 2025-04-25
13:18:49 |
| 15 | Karan | Mehta | 9123456780 |
[Link]@[Link] | Pune, Maharashtra | 2025-04-25
13:18:49 |
| 16 | Anjali | Reddy | 9012345678 |
[Link]@[Link] | Hyderabad, Telangana | 2025-04-25
13:18:49 |
| 17 | Vikram | Verma | 8899776655 |
[Link]@[Link] | Jaipur, Rajasthan | 2025-04-25
13:18:49 |
| 18 | Sneha | Desai | 9988776655 |
[Link]@[Link] | Ahmedabad, Gujarat | 2025-04-25
13:18:49 |
+-------------+------------+---------------+--------------
+--------------------------+-----------------------------------
+---------------------+
8 rows in set (0.00 sec)

mysql> select * from categories;


+-------------+------------------
+----------------------------------------------------------+
| category_id | category_name | description
|
+-------------+------------------
+----------------------------------------------------------+
| 20 | Men's Apparel | Men's fashion clothing including
shirts, t-shirts, jeans |
| 21 | Women's Clothing | Women's fashion clothing including
dresses, tops, skirts |
| 22 | Kids' Clothing | Children's clothing for ages 0-12
|
+-------------+------------------
+----------------------------------------------------------+
3 rows in set (0.00 sec)

mysql> select * from orders;


+----------+-------------+---------------------+--------------
+------------+----------------+
| order_id | customer_id | order_date | total_amount | status
| payment_status |
+----------+-------------+---------------------+--------------
+------------+----------------+
| 38 | 11 | 2025-04-25 13:54:47 | 2599.97 | Delivered
| Paid |
| 39 | 12 | 2025-04-25 13:54:47 | 1299.99 | Shipped
| Paid |
| 40 | 13 | 2025-04-25 13:54:47 | 999.98 |
Processing | Pending |
| 41 | 14 | 2025-04-25 13:54:47 | 299.99 | Delivered
| Paid |
| 42 | 15 | 2025-04-25 13:54:47 | 899.99 | Cancelled
| Refunded |
+----------+-------------+---------------------+--------------
+------------+----------------+
5 rows in set (0.00 sec)

mysql> select * from orderdetails;


+-----------------+----------+------------+----------+---------------+
| order_detail_id | order_id | product_id | quantity | price_at_time |
+-----------------+----------+------------+----------+---------------+
| 48 | 38 | 35 | 3 | 549.99 |
| 49 | 39 | 36 | 2 | 899.99 |
| 50 | 40 | 37 | 3 | 399.99 |
| 52 | 42 | 39 | 2 | 699.99 |
+-----------------+----------+------------+----------+---------------+
4 rows in set (0.00 sec)

You might also like