如何用MultiLoad工具将纯文本正确加载到Teradata VARBYTE列?
How to Preserve Original Hexadecimal Strings as VARBYTE in Teradata MultiLoad
The issue you're facing is that MultiLoad is treating your input hexadecimal strings as plain character data—each character in the input is being stored as its ASCII byte equivalent (for example, the character '3' becomes the byte 0x33, and 'f' becomes 0x66). That's why your output shows doubled-length hex values that don't match the original input.
To fix this, you need to tell MultiLoad that your input fields are hexadecimal-encoded byte data by adding the HEX attribute to your .FIELD definitions. Here's the corrected version of your MLOAD script:
.LOGTABLE dbname.log_table; .LOGON username,password; DATABASE dbname; CREATE MULTISET TABLE dbname.Table_1 (id VARBYTE(50), name VARBYTE(50)); .BEGIN IMPORT MLOAD TABLES Table_1 WORKTABLES WT_Table ERRORTABLES ET_Table UV_Table; .LAYOUT InputLayOut; -- Added HEX attribute to parse input as hex-encoded byte data .FIELD in_id * VARBYTE(100) HEX; .FIELD in_name * VARBYTE(100) HEX; .DML LABEL INSERTS IGNORE DUPLICATE INSERT ROWS; INSERT INTO dbname.Table_1 (id,name) VALUES ( :in_id,:in_name); .IMPORT INFILE test.txt FORMAT VARTEXT ',' LAYOUT InputLayOut APPLY INSERTS; .END MLOAD; .LOGOFF;
What this change does:
- The
HEXmodifier instructs MultiLoad to parse each input field as a hexadecimal string, converting it directly into the corresponding byte values. For example, the input string33526241will be converted to the bytes0x33, 0x52, 0x62, 0x41and stored in the VARBYTE column. - When you query the table later, the VARBYTE data will display as the original hexadecimal string you provided in
test.txt, matching your expected result.
内容的提问来源于stack exchange,提问作者TheBeginner
相关产品推荐
相关产品推荐

