Monday 20 September 2021

TCL Commands in MySQL, Back and Restore database

 Enter password: ****

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

Your MySQL connection id is 11

Server version: 8.0.22 MySQL Community Server - GPL


Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.


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> use kvs;

Database changed

mysql> show tables;

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

| Tables_in_kvs |

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

| dept          |

| emp           |

| emp1          |

| emp2          |

| emp3          |

| emp4          |

| emp5          |

| emp6          |

| emp7          |

| r1            |

| r2            |

| r3            |

| r4            |

| r5            |

| r6            |

| student       |

| t1            |

| t2            |

| t3            |

| t4            |

| t5            |

| t6            |

| t7            |

| voters        |

| voters1       |

| voters2       |

| voters3       |

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

27 rows in set (1.00 sec)


mysql> select * from emp;

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

| id   | name    | DOJ        | age  | salary   | subject |

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

|  102 | Sita    | 2018-12-05 |   32 | 75000.00 | Hindi   |

|  103 | Sam     | 2010-10-10 |   38 | 95000.00 | Hindi   |

|  104 | Priya   | 2019-12-05 |   28 | 72000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  106 | Amit    | 2020-12-05 |   28 | 72000.00 | Hindi   |

|  107 | Pooja   | 2021-12-10 |   28 | 65000.00 | Hindi   |

|  108 | Riya    | 2019-03-05 |   31 | 73000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  110 | Aman    | 2019-02-05 |   31 | 72000.00 | CS      |

|  109 | Rohan   | NULL       |   32 |     NULL | Hindi   |

|  111 | Shubham | 2021-10-10 |   25 | 65000.00 | Maths   |

|  112 | Ajay    | 2021-10-10 |   25 | 65000.00 | Maths   |

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

12 rows in set (0.26 sec)


mysql> update emp set salary = 70000 where id=112;

Query OK, 1 row affected (0.58 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> select * from emp;

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

| id   | name    | DOJ        | age  | salary   | subject |

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

|  102 | Sita    | 2018-12-05 |   32 | 75000.00 | Hindi   |

|  103 | Sam     | 2010-10-10 |   38 | 95000.00 | Hindi   |

|  104 | Priya   | 2019-12-05 |   28 | 72000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  106 | Amit    | 2020-12-05 |   28 | 72000.00 | Hindi   |

|  107 | Pooja   | 2021-12-10 |   28 | 65000.00 | Hindi   |

|  108 | Riya    | 2019-03-05 |   31 | 73000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  110 | Aman    | 2019-02-05 |   31 | 72000.00 | CS      |

|  109 | Rohan   | NULL       |   32 |     NULL | Hindi   |

|  111 | Shubham | 2021-10-10 |   25 | 65000.00 | Maths   |

|  112 | Ajay    | 2021-10-10 |   25 | 70000.00 | Maths   |

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

12 rows in set (0.00 sec)


mysql> rollback;

Query OK, 0 rows affected (0.02 sec)


mysql> select * from emp;

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

| id   | name    | DOJ        | age  | salary   | subject |

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

|  102 | Sita    | 2018-12-05 |   32 | 75000.00 | Hindi   |

|  103 | Sam     | 2010-10-10 |   38 | 95000.00 | Hindi   |

|  104 | Priya   | 2019-12-05 |   28 | 72000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  106 | Amit    | 2020-12-05 |   28 | 72000.00 | Hindi   |

|  107 | Pooja   | 2021-12-10 |   28 | 65000.00 | Hindi   |

|  108 | Riya    | 2019-03-05 |   31 | 73000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  110 | Aman    | 2019-02-05 |   31 | 72000.00 | CS      |

|  109 | Rohan   | NULL       |   32 |     NULL | Hindi   |

|  111 | Shubham | 2021-10-10 |   25 | 65000.00 | Maths   |

|  112 | Ajay    | 2021-10-10 |   25 | 70000.00 | Maths   |

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

12 rows in set (0.00 sec)


mysql> start transaction;

Query OK, 0 rows affected (0.00 sec)


mysql> create table account(ac_no int,balance decimal);

Query OK, 0 rows affected (2.80 sec)


mysql> desc account;

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

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

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

| ac_no   | int           | YES  |     | NULL    |       |

| balance | decimal(10,0) | YES  |     | NULL    |       |

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

2 rows in set (0.11 sec)


mysql> rollback;

Query OK, 0 rows affected (0.00 sec)


mysql> desc account;

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

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

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

| ac_no   | int           | YES  |     | NULL    |       |

| balance | decimal(10,0) | YES  |     | NULL    |       |

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

2 rows in set (0.01 sec)


mysql> show tables;

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

| Tables_in_kvs |

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

| account       |

| dept          |

| emp           |

| emp1          |

| emp2          |

| emp3          |

| emp4          |

| emp5          |

| emp6          |

| emp7          |

| r1            |

| r2            |

| r3            |

| r4            |

| r5            |

| r6            |

| student       |

| t1            |

| t2            |

| t3            |

| t4            |

| t5            |

| t6            |

| t7            |

| voters        |

| voters1       |

| voters2       |

| voters3       |

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

28 rows in set (0.01 sec)


mysql> insert into account values(100,20000),(200,10000);

Query OK, 2 rows affected (0.15 sec)

Records: 2  Duplicates: 0  Warnings: 0


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   20000 |

|   200 |   10000 |

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

2 rows in set (0.04 sec)


mysql> rollback;

Query OK, 0 rows affected (0.00 sec)


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   20000 |

|   200 |   10000 |

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

2 rows in set (0.00 sec)


mysql> update account set balance=balance-100 where ac_no=100;

Query OK, 1 row affected (0.18 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> update account set balance=balance+100 where ac_no=200;

Query OK, 1 row affected (0.14 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> rollback;

Query OK, 0 rows affected (0.00 sec)


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   19900 |

|   200 |   10100 |

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

2 rows in set (0.00 sec)


mysql> rollback;

Query OK, 0 rows affected (0.00 sec)


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   19900 |

|   200 |   10100 |

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

2 rows in set (0.00 sec)


mysql> truncate account;

Query OK, 0 rows affected (1.56 sec)


mysql> commit;

Query OK, 0 rows affected (0.00 sec)


mysql> select * from account;

Empty set (0.20 sec)


mysql> set transaction;

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 '' at line 1

mysql> start transaction;

Query OK, 0 rows affected (0.00 sec)


mysql> insert into account values(100,20000),(200,10000);

Query OK, 2 rows affected (0.01 sec)

Records: 2  Duplicates: 0  Warnings: 0


mysql> update account set balance=balance-100 where ac_no=100;

Query OK, 1 row affected (0.03 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> update account set balance=balance+100 where ac_no=200;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> rollback;

Query OK, 0 rows affected (0.09 sec)


mysql> select * from account;

Empty set (0.00 sec)


mysql> insert into account values(100,20000),(200,10000);

Query OK, 2 rows affected (0.16 sec)

Records: 2  Duplicates: 0  Warnings: 0


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   20000 |

|   200 |   10000 |

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

2 rows in set (0.00 sec)


mysql> rollback;

Query OK, 0 rows affected (0.00 sec)


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   20000 |

|   200 |   10000 |

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

2 rows in set (0.00 sec)


mysql> update account set balance=balance-100 where ac_no=100;

Query OK, 1 row affected (0.08 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> update account set balance=balance+100 where ac_no=200;

Query OK, 1 row affected (0.15 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   19900 |

|   200 |   10100 |

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

2 rows in set (0.00 sec)


mysql> rollback;

Query OK, 0 rows affected (0.00 sec)


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   19900 |

|   200 |   10100 |

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

2 rows in set (0.00 sec)


mysql> trancate account;

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 'trancate account' at line 1

mysql> truncate account;

Query OK, 0 rows affected (1.27 sec)


mysql> select * from account;

Empty set (0.24 sec)


mysql> start transaction;

Query OK, 0 rows affected (0.00 sec)


mysql> insert into account values(100,20000),(200,10000);

Query OK, 2 rows affected (0.03 sec)

Records: 2  Duplicates: 0  Warnings: 0


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   20000 |

|   200 |   10000 |

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

2 rows in set (0.00 sec)


mysql> rollback;

Query OK, 0 rows affected (0.06 sec)


mysql> select * from account;

Empty set (0.00 sec)


mysql> start transaction;

Query OK, 0 rows affected (0.00 sec)


mysql> insert into account values(100,20000),(200,10000);

Query OK, 2 rows affected (0.01 sec)

Records: 2  Duplicates: 0  Warnings: 0


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   20000 |

|   200 |   10000 |

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

2 rows in set (0.00 sec)


mysql> update account set balance=balance-100 where ac_no=100;

Query OK, 1 row affected (0.04 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> update account set balance=balance+100 where ac_no=200;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   19900 |

|   200 |   10100 |

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

2 rows in set (0.00 sec)


mysql> rollback;

Query OK, 0 rows affected (0.03 sec)


mysql> select * from account;

Empty set (0.01 sec)


mysql> start transaction;

Query OK, 0 rows affected (0.00 sec)


mysql> insert into account values(100,20000),(200,10000);

Query OK, 2 rows affected (0.01 sec)

Records: 2  Duplicates: 0  Warnings: 0


mysql> update account set balance=balance-100 where ac_no=100;

Query OK, 1 row affected (0.03 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> update account set balance=balance+100 where ac_no=200;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   19900 |

|   200 |   10100 |

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

2 rows in set (0.00 sec)


mysql> commit;

Query OK, 0 rows affected (0.13 sec)


mysql> rollback;

Query OK, 0 rows affected (0.00 sec)


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   19900 |

|   200 |   10100 |

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

2 rows in set (0.00 sec)


mysql> truncate account;

Query OK, 0 rows affected (1.14 sec)


mysql> start transaction;

Query OK, 0 rows affected (0.00 sec)


mysql> insert into account values(100,20000),(200,10000);

Query OK, 2 rows affected (0.14 sec)

Records: 2  Duplicates: 0  Warnings: 0


mysql> insert into account values(300,25000);

Query OK, 1 row affected (0.00 sec)


mysql> savepoint A;

Query OK, 0 rows affected (0.00 sec)


mysql> insert into account values(400,30000);

Query OK, 1 row affected (0.00 sec)


mysql> savepoint B;

Query OK, 0 rows affected (0.00 sec)


mysql> insert into account values(500,40000);

Query OK, 1 row affected (0.00 sec)


mysql> savepoint C;

Query OK, 0 rows affected (0.00 sec)


mysql> insert into account values(600,50000);

Query OK, 1 row affected (0.00 sec)


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   20000 |

|   200 |   10000 |

|   300 |   25000 |

|   400 |   30000 |

|   500 |   40000 |

|   600 |   50000 |

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

6 rows in set (0.00 sec)


mysql> rollback to C;

Query OK, 0 rows affected (0.00 sec)


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   20000 |

|   200 |   10000 |

|   300 |   25000 |

|   400 |   30000 |

|   500 |   40000 |

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

5 rows in set (0.03 sec)


mysql> rollback to B;

Query OK, 0 rows affected (0.03 sec)


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   20000 |

|   200 |   10000 |

|   300 |   25000 |

|   400 |   30000 |

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

4 rows in set (0.00 sec)


mysql> rollback to A;

Query OK, 0 rows affected (0.00 sec)


mysql> select * from account;

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

| ac_no | balance |

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

|   100 |   20000 |

|   200 |   10000 |

|   300 |   25000 |

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

3 rows in set (0.00 sec)


mysql> rollback;

Query OK, 0 rows affected (0.06 sec)


mysql> select * from account;

Empty set (0.00 sec)


mysql> show tables;

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

| Tables_in_kvs |

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

| account       |

| dept          |

| emp           |

| emp1          |

| emp2          |

| emp3          |

| emp4          |

| emp5          |

| emp6          |

| emp7          |

| r1            |

| r2            |

| r3            |

| r4            |

| r5            |

| r6            |

| student       |

| t1            |

| t2            |

| t3            |

| t4            |

| t5            |

| t6            |

| t7            |

| voters        |

| voters1       |

| voters2       |

| voters3       |

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

28 rows in set (0.00 sec)


mysql> drop kvs;

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 'kvs' at line 1

mysql> drop database kvs;

Query OK, 28 rows affected (7.90 sec)


mysql> show tables;

ERROR 1046 (3D000): No database selected

mysql> show databases;

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

| Database           |

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

| 12cs               |

| abc                |

| delhi              |

| information_schema |

| leet               |

| mysql              |

| performance_schema |

| pysales_inventory  |

| sakila             |

| spsc               |

| spsharmaclasses    |

| spsharmag          |

| sys                |

| world              |

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

14 rows in set (0.06 sec)


mysql> create databases kvs;

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 'databases kvs' at line 1

mysql> create database kvs;

Query OK, 1 row affected (0.09 sec)


mysql> show databases;

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

| Database           |

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

| 12cs               |

| abc                |

| delhi              |

| information_schema |

| kvs                |

| leet               |

| mysql              |

| performance_schema |

| pysales_inventory  |

| sakila             |

| spsc               |

| spsharmaclasses    |

| spsharmag          |

| sys                |

| world              |

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

15 rows in set (0.00 sec)


mysql> use kvs;

Database changed

mysql> show tables;

Empty set (0.02 sec)


mysql> show tables;

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

| Tables_in_kvs |

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

| account       |

| dept          |

| emp           |

| emp1          |

| emp2          |

| emp3          |

| emp4          |

| emp5          |

| emp6          |

| emp7          |

| r1            |

| r2            |

| r3            |

| r4            |

| r5            |

| r6            |

| student       |

| t1            |

| t2            |

| t3            |

| t4            |

| t5            |

| t6            |

| t7            |

| voters        |

| voters1       |

| voters2       |

| voters3       |

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

28 rows in set (0.09 sec)


mysql> select * from emp;

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

| id   | name    | DOJ        | age  | salary   | subject |

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

|  102 | Sita    | 2018-12-05 |   32 | 75000.00 | Hindi   |

|  103 | Sam     | 2010-10-10 |   38 | 95000.00 | Hindi   |

|  104 | Priya   | 2019-12-05 |   28 | 72000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  106 | Amit    | 2020-12-05 |   28 | 72000.00 | Hindi   |

|  107 | Pooja   | 2021-12-10 |   28 | 65000.00 | Hindi   |

|  108 | Riya    | 2019-03-05 |   31 | 73000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  110 | Aman    | 2019-02-05 |   31 | 72000.00 | CS      |

|  109 | Rohan   | NULL       |   32 |     NULL | Hindi   |

|  111 | Shubham | 2021-10-10 |   25 | 65000.00 | Maths   |

|  112 | Ajay    | 2021-10-10 |   25 | 70000.00 | Maths   |

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

12 rows in set (0.09 sec)


mysql> create table rohit as select * from emp;

Query OK, 12 rows affected, 1 warning (0.69 sec)

Records: 12  Duplicates: 0  Warnings: 1


mysql> select * from rohit;

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

| id   | name    | DOJ        | age  | salary   | subject |

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

|  102 | Sita    | 2018-12-05 |   32 | 75000.00 | Hindi   |

|  103 | Sam     | 2010-10-10 |   38 | 95000.00 | Hindi   |

|  104 | Priya   | 2019-12-05 |   28 | 72000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  106 | Amit    | 2020-12-05 |   28 | 72000.00 | Hindi   |

|  107 | Pooja   | 2021-12-10 |   28 | 65000.00 | Hindi   |

|  108 | Riya    | 2019-03-05 |   31 | 73000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  110 | Aman    | 2019-02-05 |   31 | 72000.00 | CS      |

|  109 | Rohan   | NULL       |   32 |     NULL | Hindi   |

|  111 | Shubham | 2021-10-10 |   25 | 65000.00 | Maths   |

|  112 | Ajay    | 2021-10-10 |   25 | 70000.00 | Maths   |

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

12 rows in set (0.00 sec)


mysql> create table rohit1 as select * from emp where id<110;

Query OK, 9 rows affected, 1 warning (0.81 sec)

Records: 9  Duplicates: 0  Warnings: 1


mysql> select * from rohit1;

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

| id   | name  | DOJ        | age  | salary   | subject |

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

|  102 | Sita  | 2018-12-05 |   32 | 75000.00 | Hindi   |

|  103 | Sam   | 2010-10-10 |   38 | 95000.00 | Hindi   |

|  104 | Priya | 2019-12-05 |   28 | 72000.00 | CS      |

|  105 | Raj   | 2018-01-23 |   33 | 80000.00 | CS      |

|  106 | Amit  | 2020-12-05 |   28 | 72000.00 | Hindi   |

|  107 | Pooja | 2021-12-10 |   28 | 65000.00 | Hindi   |

|  108 | Riya  | 2019-03-05 |   31 | 73000.00 | CS      |

|  105 | Raj   | 2018-01-23 |   33 | 80000.00 | CS      |

|  109 | Rohan | NULL       |   32 |     NULL | Hindi   |

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

9 rows in set (0.00 sec)


mysql> create table rohit2 as select id,name,salary from emp where id<110;

Query OK, 9 rows affected, 1 warning (0.50 sec)

Records: 9  Duplicates: 0  Warnings: 1


mysql> select * from rohit2;

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

| id   | name  | salary   |

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

|  102 | Sita  | 75000.00 |

|  103 | Sam   | 95000.00 |

|  104 | Priya | 72000.00 |

|  105 | Raj   | 80000.00 |

|  106 | Amit  | 72000.00 |

|  107 | Pooja | 65000.00 |

|  108 | Riya  | 73000.00 |

|  105 | Raj   | 80000.00 |

|  109 | Rohan |     NULL |

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

9 rows in set (0.00 sec)


mysql> create table rohit2(id int,age int);

ERROR 1050 (42S01): Table 'rohit2' already exists

mysql> create table if not exists rohit2(id int,age int);

Query OK, 0 rows affected, 1 warning (0.07 sec)


mysql> select * from rohit2;

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

| id   | name  | salary   |

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

|  102 | Sita  | 75000.00 |

|  103 | Sam   | 95000.00 |

|  104 | Priya | 72000.00 |

|  105 | Raj   | 80000.00 |

|  106 | Amit  | 72000.00 |

|  107 | Pooja | 65000.00 |

|  108 | Riya  | 73000.00 |

|  105 | Raj   | 80000.00 |

|  109 | Rohan |     NULL |

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

9 rows in set (0.00 sec)


mysql> select * from emp;

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

| id   | name    | DOJ        | age  | salary   | subject |

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

|  102 | Sita    | 2018-12-05 |   32 | 75000.00 | Hindi   |

|  103 | Sam     | 2010-10-10 |   38 | 95000.00 | Hindi   |

|  104 | Priya   | 2019-12-05 |   28 | 72000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  106 | Amit    | 2020-12-05 |   28 | 72000.00 | Hindi   |

|  107 | Pooja   | 2021-12-10 |   28 | 65000.00 | Hindi   |

|  108 | Riya    | 2019-03-05 |   31 | 73000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  110 | Aman    | 2019-02-05 |   31 | 72000.00 | CS      |

|  109 | Rohan   | NULL       |   32 |     NULL | Hindi   |

|  111 | Shubham | 2021-10-10 |   25 | 65000.00 | Maths   |

|  112 | Ajay    | 2021-10-10 |   25 | 70000.00 | Maths   |

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

12 rows in set (0.03 sec)


mysql> select * from emp where exists (select salary where id=109);

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

| id   | name  | DOJ  | age  | salary | subject |

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

|  109 | Rohan | NULL |   32 |   NULL | Hindi   |

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

1 row in set (0.04 sec)


mysql> select * from emp where exists (select salary where id=115);

Empty set (0.00 sec)


mysql> select * from emp where True;

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

| id   | name    | DOJ        | age  | salary   | subject |

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

|  102 | Sita    | 2018-12-05 |   32 | 75000.00 | Hindi   |

|  103 | Sam     | 2010-10-10 |   38 | 95000.00 | Hindi   |

|  104 | Priya   | 2019-12-05 |   28 | 72000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  106 | Amit    | 2020-12-05 |   28 | 72000.00 | Hindi   |

|  107 | Pooja   | 2021-12-10 |   28 | 65000.00 | Hindi   |

|  108 | Riya    | 2019-03-05 |   31 | 73000.00 | CS      |

|  105 | Raj     | 2018-01-23 |   33 | 80000.00 | CS      |

|  110 | Aman    | 2019-02-05 |   31 | 72000.00 | CS      |

|  109 | Rohan   | NULL       |   32 |     NULL | Hindi   |

|  111 | Shubham | 2021-10-10 |   25 | 65000.00 | Maths   |

|  112 | Ajay    | 2021-10-10 |   25 | 70000.00 | Maths   |

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

12 rows in set (0.00 sec)


mysql> select * from emp where False;

Empty set (0.00 sec)


mysql> select * from emp where id=120;

Empty set (0.00 sec)


mysql> select * from emp where id=102;

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

| id   | name | DOJ        | age  | salary   | subject |

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

|  102 | Sita | 2018-12-05 |   32 | 75000.00 | Hindi   |

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

1 row in set (0.00 sec)


mysql>





Microsoft Windows [Version 10.0.19042.1237]

(c) Microsoft Corporation. All rights reserved.


C:\WINDOWS\system32>cd C:\Program Files\MySQL\MySQL Server 8.0\bin


C:\Program Files\MySQL\MySQL Server 8.0\bin>mysqldump -uroot -proot kvs>kvsback.sql

mysqldump: [Warning] Using a password on the command line interface can be insecure.


C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -uroot -proot kvs<kvsback.sql

mysql: [Warning] Using a password on the command line interface can be insecure.


C:\Program Files\MySQL\MySQL Server 8.0\bin>