Netezza用INSERT INTO导入CSV仅得空行,请求排查问题
I’ve run into this exact issue a few times with Netezza’s external table imports—let’s walk through the most likely fixes since your flow worked before, so it’s almost certainly a parameter or subtle formatting change causing the problem:
Double-check the
REMOTESOURCE 'ODBC'file access
When usingREMOTESOURCE 'ODBC', Netezza pulls the file from your local client machine, not the server. If theC:\file.csvpath has changed permissions, the file was moved, or the ODBC driver is running under a user that can’t read it, it might be pulling a truncated or empty version of the file. Try:- Copying the CSV to a server-accessible path and switching to
REMOTESOURCE 'SERVER' - Running your query tool as an administrator to rule out permission issues
- Verifying the file size matches what you expect (if it’s suddenly 0KB or much smaller, that’s a red flag)
- Copying the CSV to a server-accessible path and switching to
Add the
QUOTECHARparameter (critical for CSV with embedded commas)
Your current query doesn’t specify a quote character, which is a common gotcha. If your CSV uses quotes around fields with commas (e.g.,"Doe, John"), Netezza will split those fields at the comma, causing misalignment and empty rows when it can’t map the data to your table’s columns. Update your query to includeQUOTECHAR '"':INSERT INTO MY_TABLE SELECT * FROM EXTERNAL 'C:\file.csv' USING ( REMOTESOURCE 'ODBC' DELIMITER ',' MAXERRORS 100000 SKIPROWS 1 ESCAPECHAR '\' QUOTECHAR '"' ) ;If your CSV uses a different quote character (like
'), adjust that accordingly. Also, confirm yourESCAPECHARis correct—some CSVs use"to escape quotes (e.g.,""instead of"), so you might needESCAPECHAR '"'instead of\.Validate CSV formatting against your table schema
Even if the CSV looks fine, small changes can break imports:- Make sure the number of columns in the CSV exactly matches
MY_TABLE—a missing column or extra header will throw off mapping, leading to empty rows. - Check line endings: Netezza prefers Unix-style
\n; Windows\r\ncan sometimes cause parsing issues. Convert the CSV to use Unix line endings (most text editors have this option) and re-test. - Look for hidden whitespace in headers or data—if your table’s columns are
user_idbut the CSV header isuser_id(with spaces), Netezza won’t map them correctly.
- Make sure the number of columns in the CSV exactly matches
Temporarily disable
SKIPROWSto test the header
You’re skipping 1 row for the header, but if the header line is malformed (e.g., missing a column name), Netezza might be treating the first data row as a header and skipping it, then importing subsequent rows incorrectly. Try running a test import to a temporary table withSKIPROWS 0to see if the header is being parsed as data—this will tell you if the header is the issue.Check Netezza logs for hidden errors
YourMAXERRORS 100000setting is letting a ton of errors slip through without triggering a failure. Head to the Netezza server’s log directory (usually/nz/kit/log) and look for logs related to external table loads—you’ll likely find warnings about parsing failures, invalid data, or permission issues that aren’t showing up in your client’s success message.
内容的提问来源于stack exchange,提问作者lykos

