Nothing Special   »   [go: up one dir, main page]

0% found this document useful (0 votes)
38 views13 pages

Mysql

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views13 pages

Mysql

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Mysql

1.For creating database


Syntax:-
create database employee;

2.For selecting database


Syntax:-
use employee;
Mysql
3. For deleting the database
Syntax:-
drop database employee;
4.For creating table:
Syntax:-
create table employee_table(id int not null
auto_increment,emp_name varchar(25) not
null,occupation varchar(200)not null,age int not
null,primary key(id));
Mysql
5. For adding new columns
Syntax:-
alter table employee_table add salary
varchar(25) not null;
6.For displaying employee table
Syntax:-
select * from employee_table;
Mysql
7.For adding multiple columns
Syntax:
alter table employee_table add Email varchar(30)
not null,add address varchar(200),add
Department varchar(200);
8.For modifying column in the table
Syntax:-
alter table employee_table modify salary int not
null;
Mysql
9. DROP column in table
Syntax:-
alter table employee_table drop column
address;
10. RENAME column in table
Syntax:-
alter table employee_table change column
occupation designation varchar(23) not null;
Mysql
11. Show/List Tables
Syntax:-
show tables from employee;
12.For Rename Table
Syntax:-
rename table employee_table to
employee_details;
Mysql
13.For inserting the values
Syntax:-
insert into employee_details
values(1,"Divya","Lecturer",32,10000,'divyamudaliar@gmail.co
m','IMCA');
OR
14)
Syntax:-
insert into
employee_details(emp_name,designation,age,salary,Email,’Dep
artment)values('Kuldeep','Manager',21,20000,'kuldeep@gmail.c
om‘,’MBA’);
Mysql
15.For inserting multiple row
Syntax:-
insert into
employee_details(emp_name,designation,age,salary
,Email)
values('Jeet','Manager',25,120000,'jeet@gmail.com'
),
('ramesh','Manager',26,120000,'ramesh@gmail.com'),
('Rahul','Developer',32,500000,'rahul@gmail.com');
Mysql
16. For displaying values particular columns
Syntax:-
select emp_name,salary,Department from
employee_details;
17.For displaying distinct keyword
Syntax:-
select distinct emp_name,salary,Department
from employee_details;
Mysql
18. Count functions
Syntax:-
select count(emp_name) from
employee_details;
19.Using as keyword:-
Syntax:-
SELECT COUNT(emp_name) as Total_employee
from employee_details;
Mysql
20.Where condition:-
Syntax:-
select emp_name,salary,Department from
employee_details where id=3;
21.Using and condition
Syntax:-
select * from employee_details where
designation='Lecturer' and
Department="IMCA";
Mysql
22.For or conditions
Syntax:-
select * from employee_details where
designation='Lecturer' or
Department="IMCA";
23. Ascending order
Syntax:
select * from employee_details order by salary;
Mysql
24.Decending order
Syntax:-
select * from employee_details order by salary
Desc;

You might also like