본문 바로가기
728x90
반응형
SMALL

MySQL16

MariaDB / MySQL 한글 깨짐 DB 서버 상태 - DBMS : mariadb 10.6.13 이 상태에서 yhkim_test 라는 database 를 utf8mb3 로 만든다. yhkim_test.test_table 을 utf8mb3 으로 만든다. ​ 이 상태에서 java application 에서 mariadb-java-client 3.0.9 driver 를 이용해서 jdbc:mariadb://127.0.0.1:3306/yhkim_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimeZone=UTC&useSSL=false 로 연결 하고 ​ select name, age from yhkim_test.test_table 하면 name.. 2024. 2. 6.
MySQL 속도 개선 TIP 1. WHERE 절에서 사용하는 컬럼은 index 를 주자. - 모두 index를 줄 수는 없으나 모든 쿼리에서 동일하게 사용하는 조건이 있다면 - 또는 자주 사용하는 where 조건이 있다면 해당 컬럼은 index를 줘도 좋을지 고민해 보자. ​ 2. 인덱스 추가한 date 컬럼 사용 시 주의점 - where 조건문의 왼쪽은 인덱스 대상이 아니기 때문에 where date_format(date) between ? and ? 하면 - 왼쪽의 date_format(date) 부분이 비효율적으로 동작한다. (인덱싱 되지 않는다.) - 유사건으로 사내 제품에서 trim(date_column)으로 하고 있는 경우가 발견되어 조치 했다. ​ 3. between 보다는 >= = and = 조건으로 사용하는 경우가 .. 2020. 9. 24.
database convert latin1 to utf-8 latin1 database converting to utf-8 1. backup mysqldump -u{username} -p{password} {dbname} --default-character-set latin1 > {dump_file_name}.sql --default-character-set latin1 이 없으면 온전하게 백업이 되지 않을 수 있다. 2. change character set iconv -c -f cp949 -t utf-8 {dump_file_name}.sql > {utf8_dump_file_name}.sql 3. change table architecture (use edit plus) ctrl + r 로 text 찾기(바꾸기) latin1 => utf8 4. drop dat.. 2014. 9. 15.
Select 후 바로 Update Function Select 후 바로 특정 column 을 +1 해야 하는 경우에 사용하는 Function 만들기 요구사항 1. 통신시 사용하는 전문번호를 DB에서 관리하고자 한다.요구사항 2. 전문번호는 매일 1번부터 시작한다.요구사항 3. 전문번호는 겹치지 않는다. Select 후 시퀀스 넘버를 바로 update 해야 하는 경우 Spring Service Interface 를 하나의 Transaction으로 묶어서 처리 하면두번의 query를 날려도 무관하나 하나의 쿼리를 통해 처리하는 것이 더욱 시퀀스 넘버를 안전하게 관리할 수 있기 때문에 아래와 같이Function을 만들어 처리 한다. (Select 후 바로 update) CREATE FUNCTION kbsavings_get_msgno () RETURNS INT.. 2014. 3. 18.
728x90
반응형
LIST