0% found this document useful (0 votes)
20 views10 pages

SQL File-2

The document outlines a series of MySQL commands used to create and manage databases and tables, specifically for client and product information, as well as student records. It includes commands for creating databases, defining table structures, inserting records, and performing basic operations such as updates and deletions. Additionally, it demonstrates the creation of a new database for project management with sample project entries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views10 pages

SQL File-2

The document outlines a series of MySQL commands used to create and manage databases and tables, specifically for client and product information, as well as student records. It includes commands for creating databases, defining table structures, inserting records, and performing basic operations such as updates and deletions. Additionally, it demonstrates the creation of a new database for project management with sample project entries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

Your MySQL connection id is 11


Server version: 8.0.42 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> create database client;


Query OK, 1 row affected (0.01 sec)

mysql> use client;


Database changed
mysql> CREATE TABLE client_master (
-> client_no VARCHAR(5),
-> name VARCHAR(20),
-> address1 VARCHAR(30),
-> address2 VARCHAR(30),
-> city VARCHAR(20),
-> state VARCHAR(20),
-> pincode INT,
-> bal_due DECIMAL(10,2)
-> );
Query OK, 0 rows affected (0.04 sec)

mysql> describe client_master;


+-----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| client_no | varchar(5) | YES | | NULL | |
| name | varchar(20) | YES | | NULL | |
| address1 | varchar(30) | YES | | NULL | |
| address2 | varchar(30) | YES | | NULL | |
| city | varchar(20) | YES | | NULL | |
| state | varchar(20) | YES | | NULL | |
| pincode | int | YES | | NULL | |
| bal_due | decimal(10,2) | YES | | NULL | |
+-----------+---------------+------+-----+---------+-------+
8 rows in set (0.07 sec)

mysql> CREATE TABLE product_master (


-> product_no VARCHAR(10),
-> description VARCHAR(30),
-> profit_percent DECIMAL(5,2),
-> unit_measure VARCHAR(10),
-> qty_on_hand INT,
-> sell_price DECIMAL(10,2),
-> cost_price DECIMAL(10,2)
-> );
Query OK, 0 rows affected (0.03 sec)

mysql> describe product_master;


+----------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------+------+-----+---------+-------+
| product_no | varchar(10) | YES | | NULL | |
| description | varchar(30) | YES | | NULL | |
| profit_percent | decimal(5,2) | YES | | NULL | |
| unit_measure | varchar(10) | YES | | NULL | |
| qty_on_hand | int | YES | | NULL | |
| sell_price | decimal(10,2) | YES | | NULL | |
| cost_price | decimal(10,2) | YES | | NULL | |
+----------------+---------------+------+-----+---------+-------+
7 rows in set (0.00 sec)
mysql> INSERT INTO client_master (client_no, name, address1, city, state,
pincode, bal_due) VALUES
-> ('001', 'IVAN', 'NAGPUR', 'NAGPUR', 'Maharashtra', 400054, 15000),
-> ('002', 'VANDANA', 'CHENNAI', 'CHENNAI', 'Tamilnadu', 780001, 0),
-> ('003', 'PRANAV', 'NAGPUR', 'NAGPUR', 'Maharashtra', 400057,
5000),
-> ('004', 'BASU', 'NAGPUR', 'NAGPUR', 'Maharashtra', 400056, 0),
-> ('005', 'RAVI', 'LUCKNOW', 'LUCKNOW', 'UP', 226025, 2000),
-> ('006', 'ARTI', 'LUCKNOW', 'LUCKNOW', 'UP', 226001, 0);
Query OK, 6 rows affected (0.01 sec)
Records: 6 Duplicates: 0 Warnings: 0
mysql> SELECT * FROM client_master;
+-----------+---------+----------+----------+---------+-------------+----
-----+----------+
| client_no | name | address1 | address2 | city | state |
pincode | bal_due |
+-----------+---------+----------+----------+---------+-------------+----
-----+----------+
| 001 | IVAN | NAGPUR | NULL | NAGPUR | Maharashtra |
400054 | 15000.00 |
| 002 | VANDANA | CHENNAI | NULL | CHENNAI | Tamilnadu |
780001 | 0.00 |
| 003 | PRANAV | NAGPUR | NULL | NAGPUR | Maharashtra |
400057 | 5000.00 |
| 004 | BASU | NAGPUR | NULL | NAGPUR | Maharashtra |
400056 | 0.00 |
| 005 | RAVI | LUCKNOW | NULL | LUCKNOW | UP |
226025 | 2000.00 |
| 006 | ARTI | LUCKNOW | NULL | LUCKNOW | UP |
226001 | 0.00 |
+-----------+---------+----------+----------+---------+-------------+----
-----+----------+
6 rows in set (0.00 sec)
mysql> INSERT INTO product_master
-> (product_no, description, profit_percent, unit_measure,
qty_on_hand, sell_price, cost_price)
-> VALUES
-> ('P07865', '1.22 floppies', 5, 'Piece', 100, 5, 500),
-> ('P00001', '1.44 floppies', 5, 'Piece', 100, 525, 50),
-> ('P08865', '1.22 Drive', 5, 'Piece', 2, 1050, 1000),
-> ('P07975', '1.44 Drive', 5, 'Piece', 10, 1050, 1000),
-> ('P07965', '540 HDD', 4, 'Piece', 10, 8400, 8000),
-> ('P03453', 'Monitors', 6, 'Piece', 1, 12000, 1120);
Query OK, 6 rows affected (0.01 sec)
Records: 6 Duplicates: 0 Warnings: 0

mysql> SELECT * FROM product_master;


+------------+---------------+----------------+--------------+-----------
--+------------+------------+
| product_no | description | profit_percent | unit_measure |
qty_on_hand | sell_price | cost_price |
+------------+---------------+----------------+--------------+-----------
--+------------+------------+
| P07865 | 1.22 floppies | 5.00 | Piece |
100 | 5.00 | 500.00 |
| P00001 | 1.44 floppies | 5.00 | Piece |
100 | 525.00 | 50.00 |
| P08865 | 1.22 Drive | 5.00 | Piece |
2 | 1050.00 | 1000.00 |
| P07975 | 1.44 Drive | 5.00 | Piece |
10 | 1050.00 | 1000.00 |
| P07965 | 540 HDD | 4.00 | Piece |
10 | 8400.00 | 8000.00 |
| P03453 | Monitors | 6.00 | Piece |
1 | 12000.00 | 1120.00 |
+------------+---------------+----------------+--------------+-----------
--+------------+------------+
6 rows in set (0.00 sec)
CREATE DATABASE College;
Query OK, 1 row affected (0.01 sec)
mysql> Use College;
Database changed
mysql> CREATE TABLE Students (
-> StudentID INT PRIMARY KEY,
-> Name VARCHAR(50),
-> Age INT,
-> Course VARCHAR(30)
-> );
Query OK, 0 rows affected (0.03 sec)

mysql> SHOW TABLES;


+-------------------+
| Tables_in_college |
+-------------------+
| students |
+-------------------+
1 row in set (0.01 sec)
mysql> INSERT INTO Students
-> (StudentID, Name , Age, Course)
-> VALUES (1, 'Abhinav Joshi' , 20 , ' Computer Science');
Query OK, 1 row affected (0.01 sec)

mysql> SELECT * FROM Students;


+-----------+---------------+------+-------------------+
| StudentID | Name | Age | Course |
+-----------+---------------+------+-------------------+
| 1 | Abhinav Joshi | 20 | Computer Science |
+-----------+---------------+------+-------------------+
1 row in set (0.00 sec)
mysql> INSERT INTO Students (StudentID, Name, Age, Course) VALUES (1,
'Abhinav', 20, 'Computer Science');
ERROR 1062 (23000): Duplicate entry '1' for key 'students.PRIMARY'
mysql> INSERT INTO Students (StudentID, Name, Age, Course) VALUES (2,
'Riya Sharma', 19, 'Mathematics');
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO Students (StudentID, Name, Age, Course) VALUES (3,
'Ankit Verma', 21, 'Physics');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Students (StudentID, Name, Age, Course) VALUES (4,
'Priya Das', 20, 'Chemistry');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Students (StudentID, Name, Age, Course) VALUES (5,
'Vikas Patel', 22, 'Biology');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Students (StudentID, Name, Age, Course) VALUES (6,
'Neha Gupta', 20, 'Economics');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Students (StudentID, Name, Age, Course) VALUES (7,
'Rahul Singh', 19, 'Statistics');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Students (StudentID, Name, Age, Course) VALUES (8,
'Sneha Roy', 21, 'English');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Students (StudentID, Name, Age, Course) VALUES (9,
'Karan Mehta', 20, 'History');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Students (StudentID, Name, Age, Course) VALUES (10,
'Ishita Jain', 22, 'Political Science');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM Students;


+-----------+---------------+------+-------------------+
| StudentID | Name | Age | Course |
+-----------+---------------+------+-------------------+
| 1 | Abhinav Joshi | 20 | Computer Science |
| 2 | Riya Sharma | 19 | Mathematics |
| 3 | Ankit Verma | 21 | Physics |
| 4 | Priya Das | 20 | Chemistry |
| 5 | Vikas Patel | 22 | Biology |
| 6 | Neha Gupta | 20 | Economics |
| 7 | Rahul Singh | 19 | Statistics |
| 8 | Sneha Roy | 21 | English |
| 9 | Karan Mehta | 20 | History |
| 10 | Ishita Jain | 22 | Political Science |
+-----------+---------------+------+-------------------+
10 rows in set (0.00 sec)
mysql> UPDATE Students SET Age = 21 WHERE StudentID = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> DELETE FROM Students WHERE StudentID = 1;


Query OK, 1 row affected (0.01 sec)

mysql> SELECT * FROM Students;


+-----------+-------------+------+-------------------+
| StudentID | Name | Age | Course |
+-----------+-------------+------+-------------------+
| 2 | Riya Sharma | 19 | Mathematics |
| 3 | Ankit Verma | 21 | Physics |
| 4 | Priya Das | 20 | Chemistry |
| 5 | Vikas Patel | 22 | Biology |
| 6 | Neha Gupta | 20 | Economics |
| 7 | Rahul Singh | 19 | Statistics |
| 8 | Sneha Roy | 21 | English |
| 9 | Karan Mehta | 20 | History |
| 10 | Ishita Jain | 22 | Political Science |
+-----------+-------------+------+-------------------+
9 rows in set (0.00 sec)
mysql> ALTER TABLE Students ADD Email VARCHAR(100);
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> SELECT * FROM Students;


+-----------+-------------+------+-------------------+-------+
| StudentID | Name | Age | Course | Email |
+-----------+-------------+------+-------------------+-------+
| 2 | Riya Sharma | 19 | Mathematics | NULL |
| 3 | Ankit Verma | 21 | Physics | NULL |
| 4 | Priya Das | 20 | Chemistry | NULL |
| 5 | Vikas Patel | 22 | Biology | NULL |
| 6 | Neha Gupta | 20 | Economics | NULL |
| 7 | Rahul Singh | 19 | Statistics | NULL |
| 8 | Sneha Roy | 21 | English | NULL |
| 9 | Karan Mehta | 20 | History | NULL |
| 10 | Ishita Jain | 22 | Political Science | NULL |
+-----------+-------------+------+-------------------+-------+
9 rows in set (0.00 sec)
mysql> DROP TABLE Students;
Query OK, 0 rows affected (0.02 sec)

mysql> SHOW TABLES;


Empty set (0.00 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| client |
| college |
| dbms_practical |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
7 rows in set (0.00 sec)
mysql> DROP Database College;
Query OK, 0 rows affected (0.03 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| client |
| dbms_practical |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
6 rows in set (0.00 sec)
mysql> CREATE DATABASE CodingJourney;
Query OK, 1 row affected (0.01 sec)

mysql> USE CodingJourney;


Database changed
mysql>
mysql> CREATE TABLE Projects (
-> ProjectID INT PRIMARY KEY,
-> Title VARCHAR(100),
-> LanguageUsed VARCHAR(50),
-> Status VARCHAR(20),
-> StartDate DATE,
-> EndDate DATE
-> );
Query OK, 0 rows affected (0.02 sec)

mysql> INSERT INTO Projects VALUES (1, 'Portfolio Website', 'HTML, CSS,
JavaScript', 'Completed', '2024-12-10', '2025-01-05');
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO Projects VALUES (2, 'Hand Gesture Volume Controller',
'Python, OpenCV, MediaPipe', 'Ongoing', '2025-01-20', NULL);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Projects VALUES (3, 'Stray Animal Roti App', 'MERN
Stack', 'Planned', '2025-06-01', NULL);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO Projects VALUES (4, 'Tic Tac Toe Game', 'Java',
'Completed', '2025-02-01', '2025-02-05');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Projects VALUES (5, 'Data Analysis Dashboard',


'Python, Pandas, Power BI', 'Completed', '2025-03-10', '2025-03-20');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Projects VALUES (6, 'Online Quiz App', 'React,
Node.js', 'Ongoing', '2025-04-01', NULL);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Projects VALUES (7, 'Library Management System',


'MySQL, Java', 'Completed', '2025-01-15', '2025-01-30');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Projects VALUES (8, 'Weather Forecast App',


'JavaScript, API', 'Completed', '2025-02-25', '2025-03-01');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Projects VALUES (9, 'Resume Builder Tool', 'Python,
Flask', 'Planned', '2025-05-10', NULL);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Projects VALUES (10, 'Student Result Analyzer', 'C++,
File Handling', 'Completed', '2024-11-10', '2024-11-20');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM Projects;


+-----------+--------------------------------+---------------------------
+-----------+------------+------------+
| ProjectID | Title | LanguageUsed
| Status | StartDate | EndDate |
+-----------+--------------------------------+---------------------------
+-----------+------------+------------+
| 1 | Portfolio Website | HTML, CSS, JavaScript
| Completed | 2024-12-10 | 2025-01-05 |
| 2 | Hand Gesture Volume Controller | Python, OpenCV, MediaPipe
| Ongoing | 2025-01-20 | NULL |
| 3 | Stray Animal Roti App | MERN Stack
| Planned | 2025-06-01 | NULL |
| 4 | Tic Tac Toe Game | Java
| Completed | 2025-02-01 | 2025-02-05 |
| 5 | Data Analysis Dashboard | Python, Pandas, Power BI
| Completed | 2025-03-10 | 2025-03-20 |
| 6 | Online Quiz App | React, Node.js
| Ongoing | 2025-04-01 | NULL |
| 7 | Library Management System | MySQL, Java
| Completed | 2025-01-15 | 2025-01-30 |
| 8 | Weather Forecast App | JavaScript, API
| Completed | 2025-02-25 | 2025-03-01 |
| 9 | Resume Builder Tool | Python, Flask
| Planned | 2025-05-10 | NULL |
| 10 | Student Result Analyzer | C++, File Handling
| Completed | 2024-11-10 | 2024-11-20 |
+-----------+--------------------------------+---------------------------
+-----------+------------+------------+
10 rows in set (0.00 sec)
mysql> SELECT * FROM Projects
-> WHERE Status = 'Completed';
+-----------+---------------------------+--------------------------+-----
------+------------+------------+
| ProjectID | Title | LanguageUsed |
Status | StartDate | EndDate |
+-----------+---------------------------+--------------------------+-----
------+------------+------------+
| 1 | Portfolio Website | HTML, CSS, JavaScript |
Completed | 2024-12-10 | 2025-01-05 |
| 4 | Tic Tac Toe Game | Java |
Completed | 2025-02-01 | 2025-02-05 |
| 5 | Data Analysis Dashboard | Python, Pandas, Power BI |
Completed | 2025-03-10 | 2025-03-20 |
| 7 | Library Management System | MySQL, Java |
Completed | 2025-01-15 | 2025-01-30 |
| 8 | Weather Forecast App | JavaScript, API |
Completed | 2025-02-25 | 2025-03-01 |
| 10 | Student Result Analyzer | C++, File Handling |
Completed | 2024-11-10 | 2024-11-20 |
+-----------+---------------------------+--------------------------+-----
------+------------+------------+
6 rows in set (0.00 sec)

mysql> SELECT COUNT(*) AS TotalProjects FROM Projects;


+---------------+
| TotalProjects |
+---------------+
| 10 |
+---------------+
1 row in set (0.01 sec)

mysql> SELECT * FROM Projects


-> ORDER BY StartDate DESC;
+-----------+--------------------------------+---------------------------
+-----------+------------+------------+
| ProjectID | Title | LanguageUsed
| Status | StartDate | EndDate |
+-----------+--------------------------------+---------------------------
+-----------+------------+------------+
| 3 | Stray Animal Roti App | MERN Stack
| Planned | 2025-06-01 | NULL |
| 9 | Resume Builder Tool | Python, Flask
| Planned | 2025-05-10 | NULL |
| 6 | Online Quiz App | React, Node.js
| Ongoing | 2025-04-01 | NULL |
| 5 | Data Analysis Dashboard | Python, Pandas, Power BI
| Completed | 2025-03-10 | 2025-03-20 |
| 8 | Weather Forecast App | JavaScript, API
| Completed | 2025-02-25 | 2025-03-01 |
| 4 | Tic Tac Toe Game | Java
| Completed | 2025-02-01 | 2025-02-05 |
| 2 | Hand Gesture Volume Controller | Python, OpenCV, MediaPipe
| Ongoing | 2025-01-20 | NULL |
| 7 | Library Management System | MySQL, Java
| Completed | 2025-01-15 | 2025-01-30 |
| 1 | Portfolio Website | HTML, CSS, JavaScript
| Completed | 2024-12-10 | 2025-01-05 |
| 10 | Student Result Analyzer | C++, File Handling
| Completed | 2024-11-10 | 2024-11-20 |
+-----------+--------------------------------+---------------------------
+-----------+------------+------------+
10 rows in set (0.00 sec)

mysql> DELETE FROM Projects


-> WHERE ProjectID = 9;
Query OK, 1 row affected (0.01 sec)

mysql> ALTER TABLE Projects


-> ADD Difficulty VARCHAR(20);
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> UPDATE Projects


-> SET Difficulty = 'Medium'
-> WHERE ProjectID IN (1, 4, 5);
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql>
mysql> UPDATE Projects
-> SET Difficulty = 'Hard'
-> WHERE ProjectID = 2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> SELECT * FROM Projects;


+-----------+--------------------------------+---------------------------
+-----------+------------+------------+------------+
| ProjectID | Title | LanguageUsed
| Status | StartDate | EndDate | Difficulty |
+-----------+--------------------------------+---------------------------
+-----------+------------+------------+------------+
| 1 | Portfolio Website | HTML, CSS, JavaScript
| Completed | 2024-12-10 | 2025-01-05 | Medium |
| 2 | Hand Gesture Volume Controller | Python, OpenCV, MediaPipe
| Ongoing | 2025-01-20 | NULL | Hard |
| 3 | Stray Animal Roti App | MERN Stack
| Planned | 2025-06-01 | NULL | NULL |
| 4 | Tic Tac Toe Game | Java
| Completed | 2025-02-01 | 2025-02-05 | Medium |
| 5 | Data Analysis Dashboard | Python, Pandas, Power BI
| Completed | 2025-03-10 | 2025-03-20 | Medium |
| 6 | Online Quiz App | React, Node.js
| Ongoing | 2025-04-01 | NULL | NULL |
| 7 | Library Management System | MySQL, Java
| Completed | 2025-01-15 | 2025-01-30 | NULL |
| 8 | Weather Forecast App | JavaScript, API
| Completed | 2025-02-25 | 2025-03-01 | NULL |
| 10 | Student Result Analyzer | C++, File Handling
| Completed | 2024-11-10 | 2024-11-20 | NULL |
+-----------+--------------------------------+---------------------------
+-----------+------------+------------+------------+
9 rows in set (0.00 sec)

You might also like