Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 8

Microsoft Windows [Version 10.0.22621.

2134]
(c) Microsoft Corporation. All rights reserved.

C:\Users\HP>cd c:\xampp\mysql\bin

c:\xampp\mysql\bin>mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.4.28-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database mis4o6;


Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> use mis4o6;


Database changed
MariaDB [mis4o6]> CREATE TABLE students (
-> student_id INT ,
-> student_name VARCHAR(40),
-> doa DATE,
-> bangla_score INT,
-> math_score INT,
-> english_score INT,
-> email VARCHAR(255)
-> );
Query OK, 0 rows affected (0.022 sec)

MariaDB [mis4o6]>
MariaDB [mis4o6]> INSERT INTO students (student_name, dob, doa, bangla_score,
math_score, english_score, email)
-> VALUES
-> ('Rahim', '2010-08-15', 90, 85, 92, 'Sachin@gmail.com'),
-> ('Karim', '2011-09-20', 88, 92, 86, 'Virat@hotmail.com'),
-> ('Jashim', '2012-06-25', 92, 94, 90, 'Rahul@yahoo.com');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
MariaDB [mis4o6]> INSERT INTO students (student_name, doa, bangla_score,
math_score, english_score, email)
-> VALUES
-> ('Rahim', '2010-08-15', 90, 85, 92, 'Sachin@gmail.com'),
-> ('Karim', '2011-09-20', 88, 92, 86, 'Virat@hotmail.com'),
-> ('Jashim', '2012-06-25', 92, 94, 90, 'Rahul@yahoo.com');
Query OK, 3 rows affected (0.004 sec)
Records: 3 Duplicates: 0 Warnings: 0

MariaDB [mis4o6]> SELECT


-> AVG(bangla_score) AS avg_bangla_score
-> from students;
+------------------+
| avg_bangla_score |
+------------------+
| 90.0000 |
+------------------+
1 row in set (0.011 sec)

MariaDB [mis4o6]> SELECT COUNT(*) AS total_students FROM students;


+----------------+
| total_students |
+----------------+
| 3 |
+----------------+
1 row in set (0.002 sec)

MariaDB [mis4o6]> SELECT


-> MIN(bangla_score) AS min_bangla_score
-> from students;
+------------------+
| min_bangla_score |
+------------------+
| 88 |
+------------------+
1 row in set (0.003 sec)

MariaDB [mis4o6]> SELECT


-> MAX(bangla_score) AS max_bangla_score
-> from students;
+------------------+
| max_bangla_score |
+------------------+
| 92 |
+------------------+
1 row in set (0.001 sec)

MariaDB [mis4o6]> SELECT


-> Min(bangla_score) AS max_bangla_score
-> from students;
+------------------+
| max_bangla_score |
+------------------+
| 88 |
+------------------+
1 row in set (0.000 sec)

MariaDB [mis4o6]> SELECT


-> SUM(bangla_score) AS total_bangla_score
-> from students;
+--------------------+
| total_bangla_score |
+--------------------+
| 270 |
+--------------------+
1 row in set (0.001 sec)

MariaDB [mis4o6]> select *from students


-> into outfile 'D:\students.csv'
-> fields terminated by ',';
ERROR 1086 (HY000): File 'D:students.csv' already exists
MariaDB [mis4o6]> CREATE TABLE stat (
-> Books INT(11),
-> Notes INT(11),
-> Pen INT(11),
-> Ribbon INT(11)
-> );
Query OK, 0 rows affected (0.022 sec)

MariaDB [mis4o6]> LOAD DATA INFILE 'D:\WO.csv'


-> INTO TABLE khabar
-> FIELDS TERMINATED BY ','
-> LINES TERMINATED BY '\n'
-> IGNORE 1 LINES;
ERROR 1146 (42S02): Table 'mis4o6.khabar' doesn't exist
MariaDB [mis4o6]> LOAD DATA INFILE 'D:\WO.csv'
-> INTO TABLE stat
-> FIELDS TERMINATED BY ','
-> LINES TERMINATED BY '\n'
-> IGNORE 1 LINES;
Query OK, 6 rows affected, 6 warnings (0.136 sec)
Records: 6 Deleted: 0 Skipped: 0 Warnings: 6

MariaDB [mis4o6]> drop table stat;


Query OK, 0 rows affected (0.036 sec)

MariaDB [mis4o6]> show tables;


+------------------+
| Tables_in_mis4o6 |
+------------------+
| students |
+------------------+
1 row in set (0.034 sec)

MariaDB [mis4o6]> SELECT VERSION();


+-----------------+
| VERSION() |
+-----------------+
| 10.4.28-MariaDB |
+-----------------+
1 row in set (0.030 sec)

MariaDB [mis4o6]> EXIT;


Bye

c:\xampp\mysql\bin>show tables;
'show' is not recognized as an internal or external command,
operable program or batch file.

c:\xampp\mysql\bin>use mis4o6;
'use' is not recognized as an internal or external command,
operable program or batch file.

c:\xampp\mysql\bin>cd c:\xampp\mysql\bin

c:\xampp\mysql\bin>mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.28-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT * FROM students


-> WHERE email REGEXP '.*@gmail.com';
ERROR 1046 (3D000): No database selected
MariaDB [(none)]> use mis4o6;
Database changed
MariaDB [mis4o6]> SELECT * FROM students
-> WHERE email REGEXP '.*@gmail.com';
+------------+--------------+------------+--------------+------------
+---------------+------------------+
| student_id | student_name | doa | bangla_score | math_score |
english_score | email |
+------------+--------------+------------+--------------+------------
+---------------+------------------+
| NULL | Rahim | 2010-08-15 | 90 | 85 |
92 | Sachin@gmail.com |
+------------+--------------+------------+--------------+------------
+---------------+------------------+
1 row in set (0.008 sec)

MariaDB [mis4o6]> create database m4i0s6;


Query OK, 1 row affected (0.006 sec)

MariaDB [mis4o6]> show databases;


+--------------------+
| Database |
+--------------------+
| 1wqe |
| 2019_1_10_058 |
| a |
| information_schema |
| m4i0s6 |
| mis406 |
| mis4o6 |
| mysql |
| performance_schema |
| phpmyadmin |
| q |
| test |
+--------------------+
12 rows in set (0.086 sec)

MariaDB [mis4o6]> use m4i0s6;


Database changed
MariaDB [m4i0s6]> drop database m4i0s6;
Query OK, 0 rows affected (0.019 sec)

MariaDB [(none)]> use mis4o6;


Database changed
MariaDB [mis4o6]> SELECT student_name, DATEDIFF(CURDATE(), dob) AS age_in_days
-> FROM students;
ERROR 1054 (42S22): Unknown column 'dob' in 'field list'
MariaDB [mis4o6]> SELECT student_name, DATEDIFF(CURDATE(), doa) AS age_in_days
-> FROM students;
+--------------+-------------+
| student_name | age_in_days |
+--------------+-------------+
| Rahim | 4772 |
| Karim | 4371 |
| Jashim | 4092 |
+--------------+-------------+
3 rows in set (0.008 sec)

MariaDB [mis4o6]> SELECT * FROM students


-> WHERE student_name LIKE '%Jashim%';
+------------+--------------+------------+--------------+------------
+---------------+-----------------+
| student_id | student_name | doa | bangla_score | math_score |
english_score | email |
+------------+--------------+------------+--------------+------------
+---------------+-----------------+
| NULL | Jashim | 2012-06-25 | 92 | 94 |
90 | Rahul@yahoo.com |
+------------+--------------+------------+--------------+------------
+---------------+-----------------+
1 row in set (0.008 sec)

MariaDB [mis4o6]> SELECT * FROM students


-> WHERE bangla_score > 90 AND math_score > 90;
+------------+--------------+------------+--------------+------------
+---------------+-----------------+
| student_id | student_name | doa | bangla_score | math_score |
english_score | email |
+------------+--------------+------------+--------------+------------
+---------------+-----------------+
| NULL | Jashim | 2012-06-25 | 92 | 94 |
90 | Rahul@yahoo.com |
+------------+--------------+------------+--------------+------------
+---------------+-----------------+
1 row in set (0.009 sec)

MariaDB [mis4o6]> SELECT * FROM students


-> WHERE bangla_score > 90 OR math_score > 90;
+------------+--------------+------------+--------------+------------
+---------------+-------------------+
| student_id | student_name | doa | bangla_score | math_score |
english_score | email |
+------------+--------------+------------+--------------+------------
+---------------+-------------------+
| NULL | Karim | 2011-09-20 | 88 | 92 |
86 | Virat@hotmail.com |
| NULL | Jashim | 2012-06-25 | 92 | 94 |
90 | Rahul@yahoo.com |
+------------+--------------+------------+--------------+------------
+---------------+-------------------+
2 rows in set (0.000 sec)

MariaDB [mis4o6]> SELECT * FROM students


-> WHERE doa BETWEEN '2010-01-01' AND '2015-12-31';
+------------+--------------+------------+--------------+------------
+---------------+-------------------+
| student_id | student_name | doa | bangla_score | math_score |
english_score | email |
+------------+--------------+------------+--------------+------------
+---------------+-------------------+
| NULL | Rahim | 2010-08-15 | 90 | 85 |
92 | Sachin@gmail.com |
| NULL | Karim | 2011-09-20 | 88 | 92 |
86 | Virat@hotmail.com |
| NULL | Jashim | 2012-06-25 | 92 | 94 |
90 | Rahul@yahoo.com |
+------------+--------------+------------+--------------+------------
+---------------+-------------------+
3 rows in set (0.025 sec)
MariaDB [mis4o6]> SELECT * FROM students
-> WHERE student_name IN ('Jashim', 'Karim');
+------------+--------------+------------+--------------+------------
+---------------+-------------------+
| student_id | student_name | doa | bangla_score | math_score |
english_score | email |
+------------+--------------+------------+--------------+------------
+---------------+-------------------+
| NULL | Karim | 2011-09-20 | 88 | 92 |
86 | Virat@hotmail.com |
| NULL | Jashim | 2012-06-25 | 92 | 94 |
90 | Rahul@yahoo.com |
+------------+--------------+------------+--------------+------------
+---------------+-------------------+
2 rows in set (0.006 sec)

MariaDB [mis4o6]> SELECT student_name, IF(bangla_score > 70, 'Pass', 'Fail') AS


bangla_result
-> FROM students;
+--------------+---------------+
| student_name | bangla_result |
+--------------+---------------+
| Rahim | Pass |
| Karim | Pass |
| Jashim | Pass |
+--------------+---------------+
3 rows in set (0.000 sec)

MariaDB [mis4o6]> SHOW TABLE STATUS LIKE 'students';


+----------+--------+---------+------------+------+----------------+-------------
+-----------------+--------------+-----------+----------------
+---------------------+---------------------+------------+--------------------
+----------+----------------+---------+------------------+-----------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length |
Max_data_length | Index_length | Data_free | Auto_increment | Create_time |
Update_time | Check_time | Collation | Checksum | Create_options |
Comment | Max_index_length | Temporary |
+----------+--------+---------+------------+------+----------------+-------------
+-----------------+--------------+-----------+----------------
+---------------------+---------------------+------------+--------------------
+----------+----------------+---------+------------------+-----------+
| students | InnoDB | 10 | Dynamic | 3 | 5461 | 16384 |
0 | 0 | 0 | NULL | 2023-09-08 23:24:28 | 2023-09-08
23:24:57 | NULL | utf8mb4_general_ci | NULL | | |
0 | N |
+----------+--------+---------+------------+------+----------------+-------------
+-----------------+--------------+-----------+----------------
+---------------------+---------------------+------------+--------------------
+----------+----------------+---------+------------------+-----------+
1 row in set (0.008 sec)

MariaDB [mis4o6]> select student_name,doa from students;


+--------------+------------+
| student_name | doa |
+--------------+------------+
| Rahim | 2010-08-15 |
| Karim | 2011-09-20 |
| Jashim | 2012-06-25 |
+--------------+------------+
3 rows in set (0.000 sec)

MariaDB [mis4o6]> CREATE VIEW high_scorers AS


-> SELECT student_name, dob, bangla_score, math_score
-> FROM students
-> WHERE bangla_score > 90 AND math_score > 90;
ERROR 1054 (42S22): Unknown column 'dob' in 'field list'
MariaDB [mis4o6]> CREATE VIEW high_scorers AS
-> SELECT student_name, doa, bangla_score, math_score
-> FROM students
-> WHERE bangla_score > 90 AND math_score > 90;
Query OK, 0 rows affected (0.036 sec)

MariaDB [mis4o6]> select *from high_scorers;


+--------------+------------+--------------+------------+
| student_name | doa | bangla_score | math_score |
+--------------+------------+--------------+------------+
| Jashim | 2012-06-25 | 92 | 94 |
+--------------+------------+--------------+------------+
1 row in set (0.018 sec)

MariaDB [mis4o6]> CREATE VIEW all_students AS


-> SELECT *
-> FROM students;
Query OK, 0 rows affected (0.019 sec)

MariaDB [mis4o6]> select *from all_students;


+------------+--------------+------------+--------------+------------
+---------------+-------------------+
| student_id | student_name | doa | bangla_score | math_score |
english_score | email |
+------------+--------------+------------+--------------+------------
+---------------+-------------------+
| NULL | Rahim | 2010-08-15 | 90 | 85 |
92 | Sachin@gmail.com |
| NULL | Karim | 2011-09-20 | 88 | 92 |
86 | Virat@hotmail.com |
| NULL | Jashim | 2012-06-25 | 92 | 94 |
90 | Rahul@yahoo.com |
+------------+--------------+------------+--------------+------------
+---------------+-------------------+
3 rows in set (0.001 sec)

MariaDB [mis4o6]> SELECT student_name, math_score


-> FROM students
-> WHERE math_score > 90;
+--------------+------------+
| student_name | math_score |
+--------------+------------+
| Karim | 92 |
| Jashim | 94 |
+--------------+------------+
2 rows in set (0.000 sec)

MariaDB [mis4o6]> SELECT YEAR(doa) AS admission_year, AVG(math_score) AS


avg_math_score
-> FROM students
-> GROUP BY admission_year
-> ORDER BY admission_year;
+----------------+----------------+
| admission_year | avg_math_score |
+----------------+----------------+
| 2010 | 85.0000 |
| 2011 | 92.0000 |
| 2012 | 94.0000 |
+----------------+----------------+
3 rows in set (0.042 sec)

MariaDB [mis4o6]> SELECT student_name, english_score


-> FROM students
-> ORDER BY english_score DESC;
+--------------+---------------+
| student_name | english_score |
+--------------+---------------+
| Rahim | 92 |
| Jashim | 90 |
| Karim | 86 |
+--------------+---------------+
3 rows in set (0.000 sec)

MariaDB [mis4o6]> INSERT INTO students (student_name, doa, bangla_score,


math_score, english_score, s email)
-> VALUES ('Gambhir', '2023-07-31', 85, 90, 88, 'gambhir@example.com');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'email)
VALUES ('Gambhir', '2023-07-31', 85, 90, 88, 'gambhir@example.com')' at line 1
MariaDB [mis4o6]> INSERT INTO students (student_name, doa, bangla_score,
math_score, english_score, s email)
-> VALUES (3,'Gambhir', '2023-07-31', 85, 90, 88, 'gambhir@example.com');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'email)
VALUES (3,'Gambhir', '2023-07-31', 85, 90, 88, 'gambhir@example.com')' at line 1
MariaDB [mis4o6]>
MariaDB [mis4o6]> DELETE FROM students
-> WHERE student_name = 'Jashim';
Query OK, 1 row affected (0.005 sec)

MariaDB [mis4o6]> UPDATE students


-> SET email ='shakib@gmail.com'
-> WHERE student_id = Rahim;
ERROR 1054 (42S22): Unknown column 'Rahim' in 'where clause'
MariaDB [mis4o6]> UPDATE students
-> SET email ='shakib@gmail.com'
-> WHERE student_name = Rahim;
ERROR 1054 (42S22): Unknown column 'Rahim' in 'where clause'
MariaDB [mis4o6]> UPDATE students
-> SET email ='shakib@gmail.com'
-> WHERE student_name = 'Rahim';
Query OK, 1 row affected (0.007 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [mis4o6]> ALTER TABLE students


-> ADD COLUMN phone_number VARCHAR(15);
Query OK, 0 rows affected (0.015 sec)
Records: 0 Duplicates: 0 Warnings: 0

You might also like