{"id":178802,"date":"2024-11-08T21:01:20","date_gmt":"2024-11-08T13:01:20","guid":{"rendered":"https:\/\/server.hk\/cnblog\/178802\/"},"modified":"2024-11-08T21:01:20","modified_gmt":"2024-11-08T13:01:20","slug":"%e5%a6%82%e4%bd%95%e4%bf%ae%e5%be%a9postgresql%e9%8c%af%e8%aa%a4%e4%bb%a3%e7%a2%bc%ef%bc%9a22p03-invalid_binary_representation%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/178802\/","title":{"rendered":"\u5982\u4f55\u4fee\u5fa9PostgreSQL\u932f\u8aa4\u4ee3\u78bc\uff1a22P03 &#8211; invalid_binary_representation\uff1f"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e4%bf%ae%e5%be%a9postgresql%e9%8c%af%e8%aa%a4%e4%bb%a3%e7%a2%bc%ef%bc%9a22p03-invalid_binary_representation-JpbVYJHPjM\">\u5982\u4f55\u4fee\u5fa9PostgreSQL\u932f\u8aa4\u4ee3\u78bc\uff1a22P03 &#8211; invalid_binary_representation<\/h1>\n<p>\u5728\u4f7f\u7528PostgreSQL\u6578\u64da\u5eab\u6642\uff0c\u958b\u767c\u8005\u53ef\u80fd\u6703\u9047\u5230\u5404\u7a2e\u932f\u8aa4\u4ee3\u78bc\uff0c\u5176\u4e2d\u4e4b\u4e00\u5c31\u662f\u932f\u8aa4\u4ee3\u78bc22P03\uff0c\u8868\u793a\u201cinvalid_binary_representation\u201d\u3002\u9019\u500b\u932f\u8aa4\u901a\u5e38\u51fa\u73fe\u5728\u6578\u64da\u8f49\u63db\u904e\u7a0b\u4e2d\uff0c\u7279\u5225\u662f\u7576\u6578\u64da\u4ee5\u4e8c\u9032\u5236\u683c\u5f0f\u5b58\u5132\u6642\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u9019\u500b\u932f\u8aa4\u7684\u539f\u56e0\u53ca\u5176\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n<h2 id=\"%e9%8c%af%e8%aa%a4%e5%8e%9f%e5%9b%a0-JpbVYJHPjM\">\u932f\u8aa4\u539f\u56e0<\/h2>\n<p>PostgreSQL\u7684\u932f\u8aa4\u4ee3\u78bc22P03\u901a\u5e38\u662f\u7531\u65bc\u4ee5\u4e0b\u5e7e\u500b\u539f\u56e0\u5f15\u8d77\u7684\uff1a<\/p>\n<ul>\n<li><strong>\u6578\u64da\u683c\u5f0f\u4e0d\u6b63\u78ba\uff1a<\/strong>\u7576\u5617\u8a66\u5c07\u4e0d\u7b26\u5408\u9810\u671f\u683c\u5f0f\u7684\u6578\u64da\u8f49\u63db\u70ba\u4e8c\u9032\u5236\u683c\u5f0f\u6642\uff0c\u6703\u5c0e\u81f4\u6b64\u932f\u8aa4\u3002\u4f8b\u5982\uff0c\u5c07\u4e00\u500b\u5b57\u7b26\u4e32\u8f49\u63db\u70ba\u6574\u6578\u6642\uff0c\u5982\u679c\u5b57\u7b26\u4e32\u5305\u542b\u975e\u6578\u5b57\u5b57\u7b26\uff0c\u5247\u6703\u51fa\u73fe\u6b64\u932f\u8aa4\u3002<\/li>\n<li><strong>\u6578\u64da\u985e\u578b\u4e0d\u5339\u914d\uff1a<\/strong>\u5982\u679c\u6578\u64da\u5eab\u4e2d\u7684\u5217\u985e\u578b\u8207\u63d2\u5165\u6216\u67e5\u8a62\u7684\u6578\u64da\u985e\u578b\u4e0d\u5339\u914d\uff0c\u4e5f\u6703\u5f15\u767c\u6b64\u932f\u8aa4\u3002\u4f8b\u5982\uff0c\u5c07\u4e00\u500b\u6d6e\u9ede\u6578\u63d2\u5165\u5230\u6574\u6578\u985e\u578b\u7684\u5217\u4e2d\u3002<\/li>\n<li><strong>\u640d\u58de\u7684\u6578\u64da\uff1a<\/strong>\u5982\u679c\u6578\u64da\u5728\u5b58\u5132\u904e\u7a0b\u4e2d\u640d\u58de\uff0c\u6216\u8005\u5728\u50b3\u8f38\u904e\u7a0b\u4e2d\u51fa\u73fe\u554f\u984c\uff0c\u4e5f\u53ef\u80fd\u5c0e\u81f4\u7121\u6cd5\u6b63\u78ba\u89e3\u6790\u4e8c\u9032\u5236\u6578\u64da\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bf%ae%e5%be%a9%e9%8c%af%e8%aa%a4-JpbVYJHPjM\">\u5982\u4f55\u4fee\u5fa9\u932f\u8aa4<\/h2>\n<p>\u4fee\u5fa9PostgreSQL\u932f\u8aa4\u4ee3\u78bc22P03\u7684\u904e\u7a0b\u901a\u5e38\u6d89\u53ca\u4ee5\u4e0b\u5e7e\u500b\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e6%aa%a2%e6%9f%a5%e6%95%b8%e6%93%9a%e6%a0%bc%e5%bc%8f-JpbVYJHPjM\">1. \u6aa2\u67e5\u6578\u64da\u683c\u5f0f<\/h3>\n<p>\u9996\u5148\uff0c\u6aa2\u67e5\u60a8\u5617\u8a66\u63d2\u5165\u6216\u67e5\u8a62\u7684\u6578\u64da\u683c\u5f0f\u3002\u78ba\u4fdd\u6240\u6709\u6578\u64da\u90fd\u7b26\u5408\u9810\u671f\u7684\u683c\u5f0f\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u8981\u63d2\u5165\u6574\u6578\uff0c\u8acb\u78ba\u4fdd\u8a72\u6578\u64da\u4e0d\u5305\u542b\u4efb\u4f55\u975e\u6578\u5b57\u5b57\u7b26\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bSQL\u67e5\u8a62\u4f86\u6aa2\u67e5\u6578\u64da\uff1a<\/p>\n<pre><code>SELECT * FROM your_table WHERE your_column !~ '^[0-9]+$';<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de\u6240\u6709\u4e0d\u7b26\u5408\u6574\u6578\u683c\u5f0f\u7684\u884c\u3002<\/p>\n<h3 id=\"2-%e7%a2%ba%e8%aa%8d%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b-JpbVYJHPjM\">2. \u78ba\u8a8d\u6578\u64da\u985e\u578b<\/h3>\n<p>\u6aa2\u67e5\u6578\u64da\u5eab\u4e2d\u5217\u7684\u6578\u64da\u985e\u578b\uff0c\u4e26\u78ba\u4fdd\u5b83\u5011\u8207\u60a8\u8981\u63d2\u5165\u7684\u6578\u64da\u985e\u578b\u76f8\u5339\u914d\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8a62\u4f86\u67e5\u770b\u8868\u7684\u7d50\u69cb\uff1a<\/p>\n<pre><code>SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'your_table';<\/code><\/pre>\n<p>\u6839\u64da\u67e5\u8a62\u7d50\u679c\uff0c\u78ba\u4fdd\u60a8\u63d2\u5165\u7684\u6578\u64da\u985e\u578b\u8207\u5217\u7684\u6578\u64da\u985e\u578b\u4e00\u81f4\u3002<\/p>\n<h3 id=\"3-%e4%bf%ae%e5%be%a9%e6%90%8d%e5%a3%9e%e7%9a%84%e6%95%b8%e6%93%9a-JpbVYJHPjM\">3. \u4fee\u5fa9\u640d\u58de\u7684\u6578\u64da<\/h3>\n<p>\u5982\u679c\u60a8\u61f7\u7591\u6578\u64da\u640d\u58de\uff0c\u60a8\u53ef\u4ee5\u8003\u616e\u5f9e\u5099\u4efd\u4e2d\u6062\u5fa9\u6578\u64da\uff0c\u6216\u8005\u4f7f\u7528\u6578\u64da\u6e05\u7406\u5de5\u5177\u4f86\u4fee\u5fa9\u640d\u58de\u7684\u6578\u64da\u3002\u78ba\u4fdd\u5728\u9032\u884c\u4efb\u4f55\u64cd\u4f5c\u4e4b\u524d\u5099\u4efd\u6578\u64da\uff0c\u4ee5\u9632\u6b62\u9032\u4e00\u6b65\u7684\u6578\u64da\u4e1f\u5931\u3002<\/p>\n<h3 id=\"4-%e4%bd%bf%e7%94%a8%e6%ad%a3%e7%a2%ba%e7%9a%84%e8%bd%89%e6%8f%9b%e5%87%bd%e6%95%b8-JpbVYJHPjM\">4. \u4f7f\u7528\u6b63\u78ba\u7684\u8f49\u63db\u51fd\u6578<\/h3>\n<p>\u5728\u9032\u884c\u6578\u64da\u8f49\u63db\u6642\uff0c\u4f7f\u7528\u6b63\u78ba\u7684\u8f49\u63db\u51fd\u6578\u53ef\u4ee5\u5e6b\u52a9\u907f\u514d\u6b64\u932f\u8aa4\u3002\u4f8b\u5982\uff0c\u4f7f\u7528 <code>CAST<\/code> \u6216 <code>::<\/code> \u4f86\u660e\u78ba\u6307\u5b9a\u6578\u64da\u985e\u578b\uff1a<\/p>\n<pre><code>SELECT your_column::integer FROM your_table;<\/code><\/pre>\n<p>\u9019\u6a23\u53ef\u4ee5\u78ba\u4fddPostgreSQL\u6b63\u78ba\u5730\u5c07\u6578\u64da\u8f49\u63db\u70ba\u6240\u9700\u7684\u985e\u578b\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-JpbVYJHPjM\">\u7e3d\u7d50<\/h2>\n<p>PostgreSQL\u932f\u8aa4\u4ee3\u78bc22P03 &#8211; invalid_binary_representation\u901a\u5e38\u662f\u7531\u65bc\u6578\u64da\u683c\u5f0f\u4e0d\u6b63\u78ba\u3001\u6578\u64da\u985e\u578b\u4e0d\u5339\u914d\u6216\u640d\u58de\u7684\u6578\u64da\u5f15\u8d77\u7684\u3002\u901a\u904e\u6aa2\u67e5\u6578\u64da\u683c\u5f0f\u3001\u78ba\u8a8d\u6578\u64da\u985e\u578b\u3001\u4fee\u5fa9\u640d\u58de\u7684\u6578\u64da\u4ee5\u53ca\u4f7f\u7528\u6b63\u78ba\u7684\u8f49\u63db\u51fd\u6578\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u6c7a\u6b64\u554f\u984c\u3002\u5c0d\u65bc\u9700\u8981\u7a69\u5b9a\u548c\u9ad8\u6548\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\u7684\u7528\u6236\uff0c\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u6216 <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u4f86\u904b\u884cPostgreSQL\u5c07\u662f\u660e\u667a\u7684\u9078\u64c7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u4fee\u5fa9PostgreSQL\u932f\u8aa4\u4ee3\u78bc22P03 &#8211; invalid_binary_representation\uff0c\u89e3\u6c7a\u6578\u64da\u683c\u5f0f\u554f\u984c\uff0c\u78ba\u4fdd\u6578\u64da\u5eab\u6b63\u5e38\u904b\u884c\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-178802","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/178802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=178802"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/178802\/revisions"}],"predecessor-version":[{"id":178803,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/178802\/revisions\/178803"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=178802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=178802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=178802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}