21.3.5 / SQL / SQL 실습, SQLD 문제풀이

pjk·2021년 3월 5일
0

[매일코딩 스터디]

목록 보기
32/62

Today

강의

MySQL 데이터베이스 한번에 끝내기 SQL Full Tutorial Course using MySQL Database (4회차 완료)

스터디 내용

  • SQL 실습 강좌 복습
  • SQLD 노란책 2과목 71번까지 풀이

결과

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;

Tomorrow

  • SQLD 2과목 96번까지 풀이
  • 실습 복습

Summary

  • 반복 반복!
profile
성장

0개의 댓글