0

如何在 MySQL 5.5 中设置多个转义字母。当我在 MySQL 5.0.22 中设置多个字母 ('\",\r,\015\n,\n,\b') 时没问题,但在 MySQL 5.5.28 中给出错误代码' ERROR 1083 (42000) :字段分隔符参数不是预期的;检查手册'我的查询如下,

select ID,MSISDN,IFNULL(TITLE,''),IFNULL(SECONDARY_TITLE,''),IFNULL (NAME,''),IFNULL(ACTIVATION_DATE,''),IFNULL(CREDIT_EXPIRY_DATE,''),
IFNULL(FIRST_VOICE_CALL_DATE,''),IFNULL(FIRST_SMS_DATE,''),IFNULL(FIRST_MMS_DATE,''),
IFNULL(FIRST_WAP_DATE,''),IFNULL(FIRST_TOPUP_DATE,''),IFNULL(TOTAL_USAGE,''),
IFNULL(TOTAL_TOPUP_AMOUNT,''),IFNULL(TOTAL_TOPUP_COUNT,''),IFNULL(LAST_TOPUP_DATE,''),
IFNULL(ACCOUNT_BALANCE,''),IFNULL(TARIFF_PLAN,''),IFNULL(DATE_OF_BIRTH,''),IFNULL(ADDRESS,''),
IFNULL(COUNTRY,''),IFNULL(CITY,''),IFNULL(POSTCODE,''),IFNULL(IC_NUMBER,''),
GENDER,IFNULL(FIXED_LINE_PHONE,''),IFNULL(EMAIL,''),IFNULL(PROFESSION,''),
IFNULL(EMPLOYER_NAME,''),IFNULL(EMPLOYER_ADDRESS,''),IFNULL(EMPLOYER_PHONE_NUMBER,''),
IFNULL(EMPLOYER_FAX_NUMBER,''),IFNULL(SIM_STATE,''),
IFNULL(ADDITIONAL_INFORMATION,'')  INTO OUTFILE '/tmp/SUBSCRIBER_PROFILE.txt'  
FIELDS ESCAPED BY '\",\\r,\\015\n,\\n,\\b' TERMINATED BY '|' 
OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n'  FROM  SUBSCRIBER_PROFILE;

但是当我在“escape by”选项中只设置一个字母时,它可以工作

请帮我解决这个问题。谢谢,达努什卡

4

1 回答 1

0

在您的情况下,转义字符应该只是“\”,因为您正在使用 \ 来转义字符。它不是要求您要转义的序列列表,只是让它知道它正在被转义的字符,在这种情况下是 \。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 使用 MySQL 5.0.21

mysql> select ID,MSISDN,IFNULL(TITLE,''),IFNULL(SECONDARY_TITLE,''),IFNULL(NAME,''),IFNULL(ACTIVATION_DATE,''),IFNULL(CREDIT_EXPIRY_DATE,''), 
    -> IFNULL(FIRST_VOICE_CALL_DATE,'') ,IFNULL(FIRST_SMS_DATE,''),IFNULL(FIRST_MMS_DATE,''),IFNULL(FIRST_WAP_DATE,''),
    -> IFNULL(FIRST_TOPUP_DATE,''),IFNULL(TOTAL_USAGE,''),IFNULL(TOTAL_TOPUP_AMOUNT,''),IFNULL(TOTAL_TOPUP_COUNT,''),
    -> IFNULL(LAST_TOPUP_DATE,''),IFNULL(ACCOUNT_BALANCE,''),IFNULL(TARIFF_PLAN,''), IFNULL(DATE_OF_BIRTH,''),IFNULL(ADDRESS,''),
    -> IFNULL(COUNTRY,''),IFNULL(CITY,''),IFNULL(POSTCODE,''),IFNULL(IC_NUMBER,''), GENDER,IFNULL(FIXED_LINE_PHONE,''),IFNULL(EMAIL,''),
    -> IFNULL(PROFESSION,''),IFNULL(EMPLOYER_NAME,''),IFNULL(EMPLOYER_ADDRESS,''), IFNULL(EMPLOYER_PHONE_NUMBER,''),
    -> IFNULL(EMPLOYER_FAX_NUMBER,''),IFNULL(SIM_STATE,''),IFNULL(ADDITIONAL_INFORMATION,'')  INTO OUTFILE '/tmp/SUBSCRIBER_PROFILE.txt' 
    ->  ***FIELDS ESCAPED BY '\",\\r,\\015\n,\\n,\\b'*** TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n'  FROM  SUBSCRIBER_PROFILE;         
*Query OK, 345812 rows affected (7.77 sec*)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 不适用于 MySQL 5.5.28

mysql> select ID,MSISDN,IFNULL(TITLE,''),IFNULL(SECONDARY_TITLE,''),IFNULL(NAME,''),IFNULL(ACTIVATION_DATE,''),IFNULL(CREDIT_EXPIRY_DATE,''), 
    -> IFNULL(FIRST_VOICE_CALL_DATE,'') ,IFNULL(FIRST_SMS_DATE,''),IFNULL(FIRST_MMS_DATE,''),IFNULL(FIRST_WAP_DATE,''),
    -> IFNULL(FIRST_TOPUP_DATE,''),IFNULL(TOTAL_USAGE,''),IFNULL(TOTAL_TOPUP_AMOUNT,''),IFNULL(TOTAL_TOPUP_COUNT,''),
    -> IFNULL(LAST_TOPUP_DATE,''),IFNULL(ACCOUNT_BALANCE,''),IFNULL(TARIFF_PLAN,''),IFNULL(DATE_OF_BIRTH,''),IFNULL(ADDRESS,''),
    -> IFNULL(COUNTRY,''),IFNULL(CITY,''),IFNULL(POSTCODE,''),IFNULL(IC_NUMBER,''),GENDER,IFNULL(FIXED_LINE_PHONE,''),IFNULL(EMAIL,''),
    -> IFNULL(PROFESSION,''),IFNULL(EMPLOYER_NAME,''),IFNULL(EMPLOYER_ADDRESS,''),IFNULL(EMPLOYER_PHONE_NUMBER,''),
    -> IFNULL(EMPLOYER_FAX_NUMBER,''),IFNULL(SIM_STATE,''),IFNULL(ADDITIONAL_INFORMATION,'')  INTO OUTFILE '/tmp/SUBSCRIBER_PROFILE.txt' 
    ->  **FIELDS ESCAPED BY '\",\\r,\\015\n,\\n,\\b'** TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n'  FROM  SUBSCRIBER_PROFILE;
*ERROR 1083 (42000): Field separator argument is not what is expected; check the manual*
于 2013-01-03T03:57:39.420 回答