mysql ɾ
ͺ̽ create database ͺ̽;
ͺ̽ Ϻ show databases;
ͺ̽ drop database ͺ̽;
ͺ̽ use ͺ̽;
̺ create table ̺(ʵ, Ÿ, );
̺ show tables;
̺ desc ̺;
ʵ ߰ alter table ̺ add ߰ ʵ Ÿ (ġ [after ʵ]);
ʵ alter table ̺ drop ʵ;
ʵ alter table ̺ change ʵ ο ʵ Ÿ;
ʵ ŸԸ alter table ̺ modify ʵ ο Ÿ;
̺ ̸ alter table ̺ rename ̺;
̺ drop ̺;
---------------------------------------------------------------------------------
ϰ ɾ mysql -u root -p ͺ̽ < ϸ
create table ep_tb(
sno int not null,
name varchar(10),
det char(20),
addr varchar(80),
tel char(20),
primary key(sno));
sql library/bin/
---------------------------------------------------------------------------------
Ϸڵ
update table name set ʵ = where ʵ = Ӽ
ex update haksa_tb set age = age - 3 where son = 2002323;
ü ڵ
update ̺ set ʵ =
update gk_tb set time = time - 1;
ڵ
delete from table name where field name = ;
ڵ (like)
delete from haksa_tb where addr like '%';
Ư ڵ (where)
delete from ̺ where age >= 20 and age <= 30;
ü üڵ
delete from table name;
myslqdump -u -p ͺ̽ > ϸ
mysql -u -p db < ϸ
̺ ڵ ˻ select *from ̺;
load data
load data infile "ؽƮ" into table ̺;
⺻ ̺ Ǿ mamp/db/mysql//.txt
ߺ ڵ尪 ؼ
select distinct ʵ from ̺;
where
select ʵ1 ʵ2 ʵ3 from ̺ where ;
(ex. select name, age, set, addr, sex from haksa_tb where sex = 'm';)
ʵ
order by ʵ sac()- ں desc() - ūں
(ex. select name,age, det, addr, sex from haksa_tb where sex='M' order by age ASC;
Limit
select *from ̺ order by ʵ asc or desc limit ;
Լ count
count(*) : ̺ ӿ ϴ ڵ
count(ʵ) : null ƴ ڵ
sum(ʵ) : ʵ հ
avg(ʵ) : ʵ
max(ʵ) : ʵ ִ밪
min(ʵ) : ʵ ּҰ
group by ʵ ȭ Ѵ.
select sno, sum(score) from jumsu_tb group by son;
group by ϰ ˻ Ϸ having ̿Ѵ.
ݵ group by ؾ Ѵ.
ex . select son from jumsu_tb group by sno having count(*) >= 2;
Ư ڿ ˻
_(ھ) ѹ ѱ 2Ʈ̹Ƿ2
̶ ̸ ã´. '__'
null ˻
select *from gk_tb where hakjum IS NULL;
null ϰ ˻
select *from gk_tb where hakjum IS NOT NULL;
join˻
2 ̻ ̺ ˻ϴ ΰ˻̶ Ѵ.
select haksa_tb.name from haksa_tb, jumsu_tb where haksa_tb.sno = jumsu.sno AND jumsu_tb.codee = 1001;