1
데이터베이스의 모든 테이블을 삭제하고 주어진 디렉토리의 모든 csv 파일을 가져 오도록 bash 스크립트를 작성하려고합니다. 그래도 난 문제의 몇 데 :csv를 sql bash로 가져 오기
ERROR 1064 (42000) at line 2: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BULK
INSERT paf_addresses
FROM '../sql/paf-sample.csv'
WITH
(
FIELDTERMINATOR = ' at line 1
는 어떻게 설정 디렉토리에있는 모든 파일에 대해 실행하는 MySQL의 일부를 알려줄 수 : 스크립트로 한 CSV 가져 오기
다음과 같은 오류를 제공합니다
내 스크립트는 다음과 같습니다.
#!/bin/bash
detail="propertystork"
AWK=$(which awk)
GREP=$(which grep)
TABLES=$(mysql -u $detail -p$detail $detail -e 'show tables' | $AWK '{ print $1}' | $GREP -v '^Tables')
for t in $TABLES
do
mysql -u $detail -p$detail $detail -e "drop table $t"
done
mysql -u $detail -p$detail -h localhost $detail <<-_END-OF-SCRIPT_
BULK
INSERT paf_addresses
FROM '../sql/paf-sample.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
_END-OF-SCRIPT_
[이] (http://blog.sqlauthority.com/2008/02/06/sql-server-import-csv-file-into-있다 벌크 삽입 -로드 - 쉼표로 분리 된 파일 - 투 - SQL 서버 /) 블로그 게시물 2008 거기 있었거나, 내가 잘못 해석했다고? –
'BULK INSERT'는 ** SQL Server ** ** ** MySQL **를위한 것이 아닙니다. 완전히 다른 데이터베이스 관리 시스템입니다. – peterm
문제를 해결해 주셔서 감사합니다. :) 1. 2 부에 대한 아이디어 ? –