You are on page 1of 8

My sql command

mysql> create database iti;

Query OK, 1 row affected (0.29 sec)

mysql> show databases;

Database
information_schema
mysql
iti
3 rows in set (0.00 sec)

mysql> use iti;

Database changed

mysql> create table copa (stu_id int (10) primary key, stu_name varchar (30),trade varchar(20));

Query OK, 0 rows affected (0.08 sec)

mysql> desc copa;

Field Type Null Key Default Extra


stu_id int(10) NO PRI NULL
stu_name varchar(30) YES NULL
trade varchar(20) YES NULL
mysql> insert into copa values (101,'mahi','copa'),(102,'raj','steno');

Query OK, 2 rows affected (0.02 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> select * from copa;

stu_id stu_name trade


101 mahi copa
102 raj steno
mysql> create table steno (emp_id int (10)primary key, salary int (15), designation varchar(30));

Query OK, 0 rows affected (0.09 sec)

mysql> desc steno;

Field Type Null Key Default Extra


emp_id int(10) NO PRI NULL

1|P ag e DIPAK KUMAR BURMAN (T.O) GOVT ITI PAMGARH


salary int(15) YES NULL
designation varchar(30) YES NULL
mysql> insert into steno (emp_id,salary,designation) values (101,25000,'training officer');

Query OK, 1 row affected (0.00 sec)

mysql> select * from steno;

emp_id salary designation


101 25000 training officer
1 row in set (0.00 sec)

mysql> show tables;

Tables_in_iti
copa

steno
mysql> alter table copa add column mobile_no int (20);

Query OK, 2 rows affected (0.11 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> desc copa;

Field Type Null Key Default Extra


stu_id int(10) NO PRI NULL
stu_name varchar(30) YES NULL
trade varchar(20) YES NULL
mobile_no int(20) YES NULL
4 rows in set (0.03 sec)

mysql> alter table copa drop column mobile_no;

Query OK, 2 rows affected (0.22 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> desc copa;

Field Type Null Key Default Extra


stu_id int(10) NO PRI NULL
stu_name varchar(30) YES NULL
trade varchar(20) YES NULL

mysql> alter table copa change column stu_name trainee_name varchar (30);
2|P ag e DIPAK KUMAR BURMAN (T.O) GOVT ITI PAMGARH
Query OK, 0 rows affected (0.38 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> desc copa;

Field Type Null Key Default Extra


stu_id int(10) NO PRI NULL
trainee_name varchar(30) YES NULL
trade varchar(20) YES NULL
mysql> select * from copa;

stu_id trainee_name trade


101 mahi copa
102 raj steno
mysql> select trainee_name from copa;

trainee_name
mahi
raj
2 rows in set (0.00 sec)

mysql> select * from copa where stu_id =102;

stu_id trainee_name trade


102 raj steno
1 row in set (0.05 sec)

mysql> select trainee_name from copa where trade='copa';

trainee_name
mahi
1 row in set (0.00 sec)

mysql> alter table employee1 modify column emp_id int (50);

mysql> select * from employee1;

emp_id emp_name designation


1 dipak kumar technician_A
2 shweta barman teacher
3 indu patwari
4 mahi raj instructor
Query OK, 0 rows affected (0.11 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> delete from employee1 where emp_id=3;

3|P ag e DIPAK KUMAR BURMAN (T.O) GOVT ITI PAMGARH


mysql> select * from employee1;

emp_id emp_name designation


1 dipak kumar technician_A
2 shweta barman teacher
4 mahi raj instructor

Query OK, 1 row affected (0.05 sec)

mysql> update employee2 set mobile_no = 7974118465 where id =1;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from employee2;

id salary posting mobile_no


1 30000 jagdalpur 7974118465
2 40000 raipur 7582866648
mysql> select * from employee1 inner join employee2 on employee1.emp_id=employee2.id;

emp_id emp_name designation id salary posting mobile_no


1 dipak kumar technician_A 1 30000 jagdalpur 7974118465
2 shweta barman teacher 2 40000 raipur 7582866648
3 indu police 3 25000 bilaspur 2147483647
4 mahi raj instructor 4 30000 dhamtari 2147483647
mysql> select employee1.emp_name,employee2.salary from employee1 inner join employee2 on
employee1.emp_id=employee2.id;

emp_name salary
dipak kumar 30000
shweta barman 40000
indu 25000
mahi raj 30000
motu 25000
5 rows in set (0.00 sec)

mysql> select * from employee1 left join employee2 on employee1.emp_id=employee2.id;

emp_id emp_name designation id salary posting mobile_no


1 dipak kumar technician_A 1 30000 jagdalpur 7974118465
2 shweta barman teacher 2 40000 raipur 7582866648
3 indu police 3 25000 bilaspur 2147483647
4 mahi raj instructor 4 30000 dhamtari 2147483647
3 motu doctor 3 25000 bilaspur 2147483647
5 rows in set (0.52 sec)
4|P ag e DIPAK KUMAR BURMAN (T.O) GOVT ITI PAMGARH
mysql> select * from employee1 right join employee2 on employee1.emp_id=employee2.id;

emp_id emp_name designation id salary posting mobile_no


1 dipak kumar technician_A 1 30000 jagdalpur 7974118465
2 shweta barman teacher 2 40000 raipur 7582866648
3 indu police 3 25000 bilaspur 2147483647
3 motu doctor 3 25000 bilaspur 2147483647
4 mahi raj instructor 4 30000 dhamtari 2147483647
5 rows in set (0.00 sec)

mysql> select * from employee2 order by id;

id salary posting mobile_no


1 30000 jagdalpur 7974118465
2 40000 raipur 7582866648
3 25000 bilaspur 2147483647
4 30000 dhamtari 2147483647
mysql> create database compony;

Query OK, 1 row affected (0.02 sec)

mysql> show databases;

Database
information_schema
compony
department
iti
mysql
5 rows in set (0.00 sec)

mysql> drop database compony;

Query OK, 0 rows affected (0.14 sec)

mysql> show databases;

Database
information_schema
department
iti
mysql
4 rows in set (0.02 sec)

mysql> create table student (id int, name varchar(20),trade varchar(50));

Query OK, 0 rows affected (0.03 sec)

mysql> desc student;


5|P ag e DIPAK KUMAR BURMAN (T.O) GOVT ITI PAMGARH
Field Type Null Key Default Extra
id Int(11) YES NULL
name varchar(20) YES NULL
trade varchar(50) YES NULL
3 rows in set (0.05 sec)

mysql> drop table student;

Query OK, 0 rows affected (0.00 sec)

mysql> create table student2 (id int, name varchar(20),trade varchar(50));

Query OK, 0 rows affected (0.17 sec)

mysql> show tables;

Tables_in_school
student2
1 row in set (0.02 sec)

mysql> desc student2;

Field Type Null Key Default Extra


id int(11) YES NULL
name varchar(20) YES NULL
trade varchar(50) YES NULL
3 rows in set (0.02 sec)

mysql> insert into student2 values (1,'mahi','csa'),(2,'raj','copa');

Query OK, 2 rows affected (0.00 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> select * from student2;

id name trade
1 mahi csa
2 raj copa
2 rows in set (0.00 sec)

mysql> truncate table student2;

Query OK, 0 rows affected (0.01 sec)

mysql> select * from student2;

Empty set (0.00 sec)

mysql> select * from teacher;

6|P ag e DIPAK KUMAR BURMAN (T.O) GOVT ITI PAMGARH


id name trade
2 sonam rac
1 row in set (0.01 sec)

mysql> delete from teacher;

Query OK, 1 row affected (0.00 sec)

mysql> select* from teacher;

Empty set (0.00 sec)

mysql> desc student2;

Field Type Null Key Default Extra

id int(11) YES NULL


name varchar(20) YES NULL
trade varchar(50) YES NULL
3 rows in set (0.02 sec)

mysql> show columns from student2;

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

id int(11) YES NULL


name varchar(20) YES NULL
trade varchar(50) YES NULL
3 rows in set (0.02 sec)

mysql> insert into student2 values (1,'amit','fitter'),(2,'sonam','rac');

Query OK, 2 rows affected (0.00 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> select * from student2;

id name trade
1 amit fitter
2 sonam rac
2 rows in set (0.00 sec)

mysql> delete from student2 where id =1;

7|P ag e DIPAK KUMAR BURMAN (T.O) GOVT ITI PAMGARH


Query OK, 1 row affected (0.00 sec)

mysql> select * from student2;

id name trade
2 sonam rac
1 row in set (0.00 sec)

mysql> rename table student2 to teacher;

Query OK, 0 rows affected (0.05 sec)

mysql> show tables;

Tables_in_school
teacher
1 row in set (0.00 sec)

8|P ag e DIPAK KUMAR BURMAN (T.O) GOVT ITI PAMGARH

You might also like