TIL 23.01.10

쓰옹·2023년 1월 10일
0

개발자를 향해~~TIL✍

목록 보기
62/87

TODAY

  • 알고리즘 풀기
  • sql강의
  • sql 프로그래머스 문제풀기
  • 스프링 시큐리티 적용하려고 노력하기

알고리즘

프로그래머스 문제 - 순서쌍의 개수, 문자열안에 문자열
(String method)

  • contains(CharSequence s)

    Returns true if and only if this string contains the specified sequence of char values.
    https://docs.oracle.com/javase/8/docs/api/

    문자열에 포함이 되었는지 확인하는 메소드

return str1.contains(str2) ? 1 : 2;

str1를 포함하고 있으면 1, 아니면 2를 리턴하도록 함

  • contains()라는 메소드가 있는지 몰라서 for문과 if문과 stream도 써보려고 노력하고 결국 검색해서 알아냈다.
  • docs를 읽어서 어떤 메소드들이 있는지 외우진 못하더라도 알아는 둬야겠다.

SQL

# world에서 데이터 가져와서 my_city에 넣어
insert into my_city select name, population from world.city; 

drop table my_city; # 테이블 삭제 속도가 빠름. 

create table my_city (id int auto_increment primary key, city_name char(35), population int);
desc my_city; # 테이블 구조 조회
insert into my_city select null, name, population from world.city; #id auto_increment

# 테이블을 남겨두고 내용은 삭제 모든 행을 삭제 . delete보다 빠름
truncate table my_city; 

insert into my_city(city_name, population) select name, population from world.city; #id auto_increment

# 값 변경
update my_city set city_name = '서울' where city_name = 'Seoul';
profile
기록하자기록해!

0개의 댓글