CSV화일 불러오기

문법

LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt'
[REPLACE | IGNORE]
INTO TABLE tbl_name
[FIELDS
    [TERMINATED BY 'string']
    [[OPTIONALLY] ENCLOSED BY 'char']
    [ESCAPED BY 'char' ]
]
[LINES
    [STARTING BY 'string']
    [TERMINATED BY 'string']
]
[IGNORE number LINES]
[(col_name_or_user_var,...)]
[SET col_name = expr,...)]

예제

LOAD DATA INFILE ' 파일경로' INFO TABLE '테이블명' FIELDS TERMINATED BY '구분자'

mysql> load data infile '/tmp/userdata.csv'
-> into table user
-> fields terminated by ','
-> LINES TERMINATED BY '\n'
-> ignore 1 lines
-> (@v1, @v2)
-> set phone = replace(@v1,'-',''),
-> userid = rtrim(ltrim(@v2));