MySQL 데이터베이스 한번에 끝내기 SQL Full Tutorial Course using MySQL Database (5회차 완료)
alter table test2 add col4 int null;
alter table test2 modify col4 varchar(40) not null;
alter table test2 drop col4;
create unique index col1idx
on test (col1);
show index from test;
alter table test add fulltext col3idx(col3);
show index from test;
alter table test drop index col3idx;
drop index col2idx on test;
create view testview as
select col1, col2
from test;
select * from testview;
alter view testview as select col1,col2,col3
from test;
drop view testview;
use world;
create view adda as
select city.Name, country.surfacearea,
city.populaton from city
join country on city.countrycode = country.code
join countrylanguage
on
city.countrycode = countrylanguage.countrycode;
insert into test value(1,123,1.1,'test');
insert into test2 select * from test;
update test set col1 = 1, col2 = 1.0, col3 = 'test'
where id = 1;
delete from test where id = 1;
truncate table test;
drop table test;
select * from city where countrycode = (
select countrycode from city where name =
'seoul');
select * from city where population > any (
select population from city where District =
'New York');
select * from city where population > all (
select population from city where District =
'New York');
select locate('abc', '1123123abc');
select left
('mysql is an open source relational ddd',5);
select right
('mysql is an open source relational ddd',5);
select lower('mysql is an open source relational');
select upper('mysql is an open source relational');
select replace('mysql','my','ms');
select trim(' sdf ');
select trim(leading '#' from '###qewf###'),
trim(trailing '#' from '###qewf###'),
trim(both '#' from '###qewf###');
select format(1231231231231,3);
select floor(10.9), ceil(10.9), round(10.9);
select date_format(now(), '%Y-%m-%d');