본문 바로가기
728x90
반응형

Programming161

[MySQL] mysql csv 입력 1. DB 테이블 구조와 CSV 파일 구조가 같은 경우. LOAD DATA LOCAL INFILE "CSV_FILE"INTO TABLE DB_TABEL FIELDS TERMINATED BY ","; 2. DB 테이블 구조와 CSV 파일 구조가 다른 경우. LOAD DATA LOCAL INFILE 'CSV_FILE'INTO TABLE DB_TABELFIELDS TERMINATED BY ','ENCLOSED BY '"'LINES TERMINATED BY '\n' (column_name1,column_name2,column_name3, ...); 3. CSV 파일이 한글일 경우 LOAD DATA LOCAL INFILE 'CSV_FILE'INTO TABLE DB_TABELcharacter set utf8 ​ /.. 2015. 6. 30.
auto_increment initialization (초기화) auto_increment를 이용하여 DB에 데이터를 쌓다보면 auto_increment가 어마어마하게 쌓여있는걸 볼수 있다. tabel을 초기화할 경우 auto_increment도 초기화를 해야 할 경우가 있다. alter table '테이블명' auto_increment = 1 위의 sql문을 이용하여 auto_increment를 초기화 하고 사용하면 된다. 2015. 6. 30.
[MySQL] 컬럼 & 필드 합치기 concat(), group_concat() concat() ex ) concat(column, column) item_table​idx category1category2 category3 5 1 2 3 select idx, concat(category1, "/", category2, "/", category3) as merge_column from item_table where idx = 5 idx merge_column 5 1/2/3 group_concat() ex) group_concat(field saparator '구분자') item_table idx category 5 1 5 2 5 3 select idx, group_concat(category saparator '/') as group_concatfrom item_tablewhere .. 2015. 6. 30.
[MySQL] 문자 치환하기 REPLACE() REPLACE(field, '수정 전', '수정 후'); ex)update 테이블 set 컬럼=replace(컬럼 ,'수정 전','수정 후');update coordi_type_table set coordi_type=replace(coordi_type, 'a' , 'b' ); coordi_type_table coordi_type (치환 전) coordi_type(치환 후) a b 2015. 6. 30.
728x90
반응형