Sql Commands

C:\Users\AASHISH>mysql -h localhost -u root -p <type enter>
Enter password:

MariaDB [(none)]> create database company;
Query OK, 1 row affected (0.04 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| company            |
| information_schema |
| mysql              |
| performance_schema |
| phpmyadmin         |
| test               |
+--------------------+
6 rows in set (0.01 sec)

MariaDB [(none)]> use company
Database changed
MariaDB [company]>



MariaDB [(none)]> use company
Database changed
MariaDB [company]>
MariaDB [company]> create table info (emailid varchar(25),password varchar(25));
Query OK, 0 rows affected (0.23 sec)
MariaDB [company]> show tables;
+-------------------+
| Tables_in_company |
+-------------------+
| info              |
+-------------------+
1 row in set (0.00 sec)

MariaDB [company]> insert into info values('a@gmail.com','1234');
Query OK, 1 row affected (0.04 sec)

MariaDB [company]> insert into info values('b@gmail.com','1234');
Query OK, 1 row affected (0.04 sec)

MariaDB [company]> select * from info;
+-------------+----------+
| emailid     | password |
+-------------+----------+
| a@gmail.com | 1234     |
| b@gmail.com | 1234     |
+-------------+----------+
2 rows in set (0.00 sec)


MariaDB [company]> select * from info where emailid like 'a@gmail.com';
+-------------+----------+
| emailid     | password |
+-------------+----------+
| a@gmail.com | 1234     |
+-------------+----------+
1 row in set (0.01 sec)

MariaDB [company]> update info set password='12345678' where emailid like 'a@gmail.com'
    -> ;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [company]> select * from info;
+-------------+----------+
| emailid     | password |
+-------------+----------+
| a@gmail.com | 12345678 |
| b@gmail.com | 1234     |
+-------------+----------+
2 rows in set (0.00 sec)


ALTER TABLE `info` ADD PRIMARY KEY( `emailid`);


MariaDB [company]> drop table info;

MariaDB [company]> drop database company;
Query OK, 0 rows affected (0.00 sec)
Reactions:

0 comments:

Post a Comment