0% found this document useful (0 votes)
3 views

SQL

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

SQL

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Setting environment for using XAMPP for Windows.

cpava@COMPUTER c:\Users\cpava\OneDrive\Desktop\xampp
# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.4.32-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)]> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
+--------------------+
5 rows in set (0.052 sec)

MariaDB [(none)]> create database Storage;


Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
| storage |
| test |
+--------------------+
6 rows in set (0.002 sec)

MariaDB [(none)]> use storage;


Database changed
MariaDB [storage]> create table stddet(Rno int(3), Name char(15), Marks int(2))
-> create table stddet(Rno int(3), Name char(15), Marks int(2));
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 'create
table stddet(Rno int(3), Name char(15), Marks int(2))' at line 2
MariaDB [storage]> create table stddet(Rno int(3), Name char(15), Marks int(2));
Query OK, 0 rows affected (0.010 sec)

MariaDB [storage]> show tables;


+-------------------+
| Tables_in_storage |
+-------------------+
| stddet |
+-------------------+
1 row in set (0.001 sec)
MariaDB [storage]> desc stddet;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| Rno | int(3) | YES | | NULL | |
| Name | char(15) | YES | | NULL | |
| Marks | int(2) | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.021 sec)

MariaDB [storage]> Insert into stddet(Rno, Name, Marks) values(101,'RAM',23);


Query OK, 1 row affected (0.082 sec)

MariaDB [storage]> select * from stddet;


+------+------+-------+
| Rno | Name | Marks |
+------+------+-------+
| 101 | RAM | 23 |
+------+------+-------+
1 row in set (0.001 sec)

MariaDB [storage]> Insert into stddet(Rno, Name, Marks) values(102,'RAVI',20);


Query OK, 1 row affected (0.026 sec)

MariaDB [storage]> Insert into stddet values(103,'RAJU',22);


Query OK, 1 row affected (0.026 sec)

MariaDB [storage]> Insert into stddet values(104,'RAJU',22),(105,'RAJ',24);


Query OK, 2 rows affected (0.026 sec)
Records: 2 Duplicates: 0 Warnings: 0

MariaDB [storage]> select * from stddet;


+------+------+-------+
| Rno | Name | Marks |
+------+------+-------+
| 101 | RAM | 23 |
| 102 | RAVI | 20 |
| 103 | RAJU | 22 |
| 104 | RAJU | 22 |
| 105 | RAJ | 24 |
+------+------+-------+
5 rows in set (0.001 sec)

MariaDB [storage]> Delete from stddet where (Rno=104, Name=RAJU, Marks=22);


ERROR 1054 (42S22): Unknown column 'RAJU' in 'where clause'
MariaDB [storage]> Delete from stddet where Rno=104;
Query OK, 1 row affected (0.025 sec)

MariaDB [storage]> select * from stddet;


+------+------+-------+
| Rno | Name | Marks |
+------+------+-------+
| 101 | RAM | 23 |
| 102 | RAVI | 20 |
| 103 | RAJU | 22 |
| 105 | RAJ | 24 |
+------+------+-------+
4 rows in set (0.000 sec)
MariaDB [storage]> Insert into stddet values(104,'RAMY',21);
Query OK, 1 row affected (0.026 sec)

MariaDB [storage]> select * from stddet;


+------+------+-------+
| Rno | Name | Marks |
+------+------+-------+
| 101 | RAM | 23 |
| 102 | RAVI | 20 |
| 103 | RAJU | 22 |
| 105 | RAJ | 24 |
| 104 | RAMY | 21 |
+------+------+-------+
5 rows in set (0.000 sec)

MariaDB [storage]> Insert into stddet values(106,'RAMY',22);


Query OK, 1 row affected (0.026 sec)

MariaDB [storage]> select * from stddet;


+------+------+-------+
| Rno | Name | Marks |
+------+------+-------+
| 101 | RAM | 23 |
| 102 | RAVI | 20 |
| 103 | RAJU | 22 |
| 105 | RAJ | 24 |
| 104 | RAMY | 21 |
| 106 | RAMY | 22 |
+------+------+-------+
6 rows in set (0.001 sec)

MariaDB [storage]> update stddet set Name='RAMY' where Rno=106;


Query OK, 0 rows affected (0.001 sec)
Rows matched: 1 Changed: 0 Warnings: 0

MariaDB [storage]> select * from stddet;


+------+------+-------+
| Rno | Name | Marks |
+------+------+-------+
| 101 | RAM | 23 |
| 102 | RAVI | 20 |
| 103 | RAJU | 22 |
| 105 | RAJ | 24 |
| 104 | RAMY | 21 |
| 106 | RAMY | 22 |
+------+------+-------+
6 rows in set (0.001 sec)

MariaDB [storage]> update stddet set Name='RAMYA' where Rno=106;


Query OK, 1 row affected (0.027 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [storage]> select * from stddet;


+------+-------+-------+
| Rno | Name | Marks |
+------+-------+-------+
| 101 | RAM | 23 |
| 102 | RAVI | 20 |
| 103 | RAJU | 22 |
| 105 | RAJ | 24 |
| 104 | RAMY | 21 |
| 106 | RAMYA | 22 |
+------+-------+-------+
6 rows in set (0.001 sec)

MariaDB [storage]> select Rno, Name from stddet;


+------+-------+
| Rno | Name |
+------+-------+
| 101 | RAM |
| 102 | RAVI |
| 103 | RAJU |
| 105 | RAJ |
| 104 | RAMY |
| 106 | RAMYA |
+------+-------+
6 rows in set (0.001 sec)

MariaDB [storage]> select rno, marks from stddet where rno<=14;


Empty set (0.001 sec)

MariaDB [storage]> select * from stddet;


+------+-------+-------+
| Rno | Name | Marks |
+------+-------+-------+
| 101 | RAM | 23 |
| 102 | RAVI | 20 |
| 103 | RAJU | 22 |
| 105 | RAJ | 24 |
| 104 | RAMY | 21 |
| 106 | RAMYA | 22 |
+------+-------+-------+
6 rows in set (0.001 sec)

MariaDB [storage]> select rno, marks from stddet where rno>=14;


+------+-------+
| rno | marks |
+------+-------+
| 101 | 23 |
| 102 | 20 |
| 103 | 22 |
| 105 | 24 |
| 104 | 21 |
| 106 | 22 |
+------+-------+
6 rows in set (0.001 sec)

MariaDB [storage]> save


-> select * from stddet;
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 'save
select * from stddet' at line 1
MariaDB [storage]> select * from stddet;
+------+-------+-------+
| Rno | Name | Marks |
+------+-------+-------+
| 101 | RAM | 23 |
| 102 | RAVI | 20 |
| 103 | RAJU | 22 |
| 105 | RAJ | 24 |
| 104 | RAMY | 21 |
| 106 | RAMYA | 22 |
+------+-------+-------+
6 rows in set (0.001 sec)

You might also like