MySQL 데이터베이스 한번에 끝내기 SQL Full Tutorial Course using MySQL Database (4회차 완료)
select sqrt(5);
select sin(pi());
select abs(-3), rand(), round(rand()*100, 0);
select now(), curdate(), curtime();
select now(), date(now()), month(now()), hour(now()), day(now());
select monthname(now()), dayname(now());
select dayofmonth(now()), dayofyear(now()), dayofweek(now());
select date_format(now(), '%Y %m %d');
use world;
drop table city2;
create table city2 as select * from city;
select * from city2;
create database pjk;
use pjk;
create table test2 (
id int not null primary key,
col1 int null,
col2 float null,
col3 varchar(45) null
);
desc test2;
select * from test2;
#alter
alter table test2 add col4 int null;
alter table test2 modify col4 varchar(40) null;
alter table test2 drop col4;
create index col1idx on test2 (col1);
show index from test2;
create unique index col2idx on test2 (col2);
show index from test2;
alter table test2 add fulltext col3idx (col3);
show index from test2;
alter table test2 drop index col3idx;
drop index col2idx on test2;
create view testview as select col1, col2 from test2;
select * from testview;
alter view testview as select col1, col2, col3 from test2;
drop view testview;
use world;
drop view allview;
create view allview as select city.name, country.surfacearea, city.population from city join country on city.countrycode = country.code
join countrylanguage on city.countrycode = countrylanguage.countrycode where city.countrycode = 'KOR';
select * from allview;
use pjk;
insert into test2 value(1, 123, 1.1, 'test');
insert into test2 value(3,444, 2.5, 'tteess');
select * from test2;
create table test (id int not null primary key,
col1 int not null,
col2 float not null,
col3 varchar(40) null);
insert into test select * from test2;
update test set col1 = 1, col2 = 3, col3 = 'sdaofj' where id = 1;
select * from test;
delete from test where id = 1;
select * from test;
truncate table test;
select * from test;
drop table test;
drop table test2;
drop database pjk;
drop view allview;