0% found this document useful (0 votes)
11 views3 pages

Assignment 1 Database

The document details a MySQL session where a user attempts to create and manipulate a database named 'UniversityLibrary'. It includes commands for creating tables, inserting records, and querying data, showing successful operations and error messages for incorrect syntax. The final output displays the updated list of books in the database after an update operation.

Uploaded by

muiz the dizi
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
11 views3 pages

Assignment 1 Database

The document details a MySQL session where a user attempts to create and manipulate a database named 'UniversityLibrary'. It includes commands for creating tables, inserting records, and querying data, showing successful operations and error messages for incorrect syntax. The final output displays the updated list of books in the database after an update operation.

Uploaded by

muiz the dizi
Copyright
© © All Rights Reserved
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
You are on page 1/ 3

MOHAMAD MUIZZUDDIN BIN MOHD SAAT (23BT01011)

MUHAMMAD HAFIZUDDIN BIN SHAHRAFUDDIN (23BT02017)

C:\laragon\www
λ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.30 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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 DATABE UniversityLibrary;


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 'DATABE
UniversityLibrary' at line 1
mysql> CREATE DATABASE UniversityLibrary;
ERROR 1007 (HY000): Can't create database 'universitylibrary'; database exists
mysql> USE UniversityLibrary;
Database changed
mysql> CREATE TABLE Books (BOOK_ID INT PRIMARY KEY , BOOK_TITLE VARCHAR(30),
BOOK_AUTHOR VARCHAR (30), BOOK_SUBJECT VARCHAR(30), AVERAGE_COST DECIMAL(10,2) ,
PUBLICATION_YEAR INT);
ERROR 1050 (42S01): Table 'books' already exists
mysql> INSERT INTO Books (BOOK_ID, BOOK_TITLE, BOOK_AUTHOR, BOOK_SUBJECT,
AVERAGE_COST, PUBLICATION_YEAR) VALUES
-> (101, 'SQL BASICS', 'JOHN SMITH', 'DATABASE', 65.50, 2019),
-> (102, 'ADVANCE PYTHON', 'JANE DOE', 'PROGRAMMING', 80.00, 2021),
-> (103, 'CLOUD COMPUTING', 'MICHAEL LEE', 'CLOUD', 90.00, 2020),
-> (104, 'DATA SCIENCE 101', 'EMILY DAVIS', 'DATA SCIENCE', 75.00, 2022),
-> (105, 'WEB DEVELOPMENT', 'ROBERT BROWN', 'WEB', 85.00, 2018),
-> (106, 'MACHINE LEARNING', 'SOPHIA WILSON', 'AI', 95.00, 2021),
-> (107, 'CYBER SECURITY ESSENTIALS', 'DAVID CLARK', 'SECURITY', 88.00,
2020),
-> (108, 'BIG DATA ANALYTICS', 'OLIVIA MARTINEZ', 'DATA SCIENCE', 92.50,
2019),
-> (109, 'MOBILE APP DEVELOPMENT', 'JAMES TAYLOR', 'MOBILE', 78.50, 2023),
-> (110, 'BLOCKCHAIN FUNDAMENTALS', 'EMMA JOHNSON', 'BLOCKCHAIN', 89.00,
2022);
Query OK, 10 rows affected (2.15 sec)
Records: 10 Duplicates: 0 Warnings: 0

mysql> SELECT * FROM Books;


+---------+---------------------------+-----------------+--------------
+--------------+------------------+
| BOOK_ID | BOOK_TITLE | BOOK_AUTHOR | BOOK_SUBJECT |
AVERAGE_COST | PUBLICATION_YEAR |
+---------+---------------------------+-----------------+--------------
+--------------+------------------+
| 101 | SQL BASICS | JOHN SMITH | DATABASE |
65.50 | 2019 |
| 102 | ADVANCE PYTHON | JANE DOE | PROGRAMMING |
80.00 | 2021 |
| 103 | CLOUD COMPUTING | MICHAEL LEE | CLOUD |
90.00 | 2020 |
| 104 | DATA SCIENCE 101 | EMILY DAVIS | DATA SCIENCE |
75.00 | 2022 |
| 105 | WEB DEVELOPMENT | ROBERT BROWN | WEB |
85.00 | 2018 |
| 106 | MACHINE LEARNING | SOPHIA WILSON | AI |
95.00 | 2021 |
| 107 | CYBER SECURITY ESSENTIALS | DAVID CLARK | SECURITY |
88.00 | 2020 |
| 108 | BIG DATA ANALYTICS | OLIVIA MARTINEZ | DATA SCIENCE |
92.50 | 2019 |
| 109 | MOBILE APP DEVELOPMENT | JAMES TAYLOR | MOBILE |
78.50 | 2023 |
| 110 | BLOCKCHAIN FUNDAMENTALS | EMMA JOHNSON | BLOCKCHAIN |
89.00 | 2022 |
+---------+---------------------------+-----------------+--------------
+--------------+------------------+
10 rows in set (0.00 sec)

mysql> SELECT BOOK_ID,BOOK_TITLE,AVERAGE_COST FROM Books WHERE BOOK_SUBJECT = 'AI';


+---------+------------------+--------------+
| BOOK_ID | BOOK_TITLE | AVERAGE_COST |
+---------+------------------+--------------+
| 106 | MACHINE LEARNING | 95.00 |
+---------+------------------+--------------+
1 row in set (0.00 sec)

mysql> SELECT BOOK_ID,BOOK_TITLE,BOOK_SUBJECT,PUBLICATION_YEAR FROM Books WHERE


AVERAGE_COST > 80;
+---------+---------------------------+--------------+------------------+
| BOOK_ID | BOOK_TITLE | BOOK_SUBJECT | PUBLICATION_YEAR |
+---------+---------------------------+--------------+------------------+
| 103 | CLOUD COMPUTING | CLOUD | 2020 |
| 105 | WEB DEVELOPMENT | WEB | 2018 |
| 106 | MACHINE LEARNING | AI | 2021 |
| 107 | CYBER SECURITY ESSENTIALS | SECURITY | 2020 |
| 108 | BIG DATA ANALYTICS | DATA SCIENCE | 2019 |
| 110 | BLOCKCHAIN FUNDAMENTALS | BLOCKCHAIN | 2022 |
+---------+---------------------------+--------------+------------------+
6 rows in set (0.00 sec)

mysql> UPDATE Books SET BOOK_TITLE = 'ADVANCE CLOUD SECURITY', AVERAGE_COST = *


1.05 WHERE BOOK_ID = 103;
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 '* 1.05
WHERE BOOK_ID = 103' at line 1
mysql> UPDATE Books SET BOOK_TITLE = 'ADVANCE CLOUD SECURITY', AVERAGE_COST = 94.5
WHERE BOOK_ID = 103;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> SELECT * FROM Books;


+---------+---------------------------+-----------------+--------------
+--------------+------------------+
| BOOK_ID | BOOK_TITLE | BOOK_AUTHOR | BOOK_SUBJECT |
AVERAGE_COST | PUBLICATION_YEAR |
+---------+---------------------------+-----------------+--------------
+--------------+------------------+
| 101 | SQL BASICS | JOHN SMITH | DATABASE |
65.50 | 2019 |
| 102 | ADVANCE PYTHON | JANE DOE | PROGRAMMING |
80.00 | 2021 |
| 103 | ADVANCE CLOUD SECURITY | MICHAEL LEE | CLOUD |
94.50 | 2020 |
| 104 | DATA SCIENCE 101 | EMILY DAVIS | DATA SCIENCE |
75.00 | 2022 |
| 105 | WEB DEVELOPMENT | ROBERT BROWN | WEB |
85.00 | 2018 |
| 106 | MACHINE LEARNING | SOPHIA WILSON | AI |
95.00 | 2021 |
| 107 | CYBER SECURITY ESSENTIALS | DAVID CLARK | SECURITY |
88.00 | 2020 |
| 108 | BIG DATA ANALYTICS | OLIVIA MARTINEZ | DATA SCIENCE |
92.50 | 2019 |
| 109 | MOBILE APP DEVELOPMENT | JAMES TAYLOR | MOBILE |
78.50 | 2023 |
| 110 | BLOCKCHAIN FUNDAMENTALS | EMMA JOHNSON | BLOCKCHAIN |
89.00 | 2022 |
+---------+---------------------------+-----------------+--------------
+--------------+------------------+
10 rows in set (0.00 sec)

mysql>

You might also like