{"id":4451,"date":"2019-08-17T10:32:57","date_gmt":"2019-08-17T02:32:57","guid":{"rendered":"https:\/\/www.xttblog.com\/?p=4451"},"modified":"2019-08-17T10:32:57","modified_gmt":"2019-08-17T02:32:57","slug":"postgresql%e7%9a%84%e4%b8%a4%e7%a7%8d%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2%e6%96%b9%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4451","title":{"rendered":"PostgreSQL\u7684\u4e24\u79cd\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u65b9\u5f0f"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">PostgreSQL \u5728\u56fd\u5916\u5f88\u706b\uff0c\u5728\u56fd\u5185\u53d1\u5c55\u7684\u4e0d\u5982 MySQL\uff0c\u4f46\u4e5f\u6709\u4eba\u4f7f\u7528\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e24\u5e74 PostgreSQL \u5728\u56fd\u5185\u7684\u53d1\u5c55\u4e5f\u987a\u98ce\u987a\u6c34\u3002\u793e\u533a\uff0c\u5927\u4f1a\uff0c\u57f9\u8bad\u7b49\u4e5f\u662f\u4e00\u573a\u63a5\u4e00\u573a\u7684\u641e\u3002\u5982\u679c\u8bf4\uff0cPostgreSQL \u53d1\u5c55\u7684\u52bf\u5934\u5f88\u597d\u4e5f\u4e0d\u4e3a\u8fc7\uff0c\u4e3b\u8981\u662f MySQL \u88ab Oracle \u6536\u8d2d\u540e\uff0c\u91cd\u5fc3\u4e0d\u5728 MySQL \u4e0a\u4e86\u3002\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48 MySQL \u51fa\u73b0\u4e86\u5f88\u591a\u7684\u5206\u652f\uff0c\u6bd4\u5982\uff1aAliSQL\u3001MariaDB \u7b49\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4eca\u5929\u6211\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4e24\u79cd PostgreSQL \u7684\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u65b9\u5f0f\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcly1g62gwd2exej219q0oi7nx.jpg\" alt=\"\" \/><figcaption>PostgreSQL \u6570\u636e\u5e93\u4f7f\u7528\u6559\u7a0b<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u4f7f\u7528\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u4e4b\u524d\uff0c\u540c\u6837\u7684 SQL \u5728\u6709\u7684\u670d\u52a1\u5668\u4e0d\u62a5\u9519\uff0c\u4e3b\u8981\u662f\u6570\u636e\u5e93\u7684\u7248\u672c\u4e0d\u540c\uff0c\u5f53\u7136\u8be5\u8fc7\u914d\u7f6e\u7684\u4e0d\u7b97\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5e38\u89c1\u7684\u4e24\u79cd\u7c7b\u578b\u8f6c\u6362\u9519\u8bef\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">ERROR: operator does not exist: integer = character varying<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">ERROR: operator does not exist: character varying = integer<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b57\u7b26\u4e32\u8f6c\u6570\u5b57\uff0c\u6570\u5b57\u8f6c\u5b57\u7b26\u4e32\u3002\u8fd9\u4e00\u70b9\u652f\u6301\u7684\u4e0d\u5982 MySQL \u597d\uff0c\u5f53\u7136 PostgreSQL \u5728\u65b0\u7248\u672c\u4e2d\u4e5f\u5bf9\u8fd9\u4e2a\u95ee\u9898\u505a\u4e86\u6539\u8fdb\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e00\u79cd\u8f6c\u6362\u65b9\u5f0f\uff1a\u4f7f\u7528 CAST \u51fd\u6570\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM xttblog WHERE id = CAST(888 AS VARCHAR);\nSELECT * FROM xttblog WHERE id = CAST('888' AS integer);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e8c\u79cd\u8f6c\u6362\u65b9\u5f0f\uff1a\u4f7f\u7528\u201c::\u201d\u64cd\u4f5c\u5b57\u6bb5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u683c\u5f0f\uff0c\u5b57\u6bb5 :: \u4f60\u8981\u8f6c\u6362\u4e3a\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM xttblog WHERE id = 888 :: VARCHAR;\nSELECT * FROM xttblog WHERE id = '888' :: integer;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6570\u636e\u7c7b\u578b\u8f6c\u6362\uff0c\u867d\u7136\u770b\u8d77\u6765\u5f88\u75db\u82e6\uff0c\u4f46\u662f\u5982\u679c\u4f60\u7684\u7c7b\u578b\u7528\u7684\u4e0d\u5bf9\uff0c\u67e5\u8be2\u6548\u7387\u4f1a\u4e0b\u964d\u3002\u6240\u4ee5\uff0c\u5728\u8bbe\u8ba1\u7684\u65f6\u5019\uff0c\u5b57\u6bb5\u7684\u7c7b\u578b\uff0c\u4e00\u5b9a\u8981\u8bbe\u8ba1\u7684\u5408\u7406\uff0c\u5c24\u5176\u662f\u5728\u5173\u8054\u8868\u7684\u65f6\u5019\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=4451\">PostgreSQL\u7684\u4e24\u79cd\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u65b9\u5f0f<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>PostgreSQL \u5728\u56fd\u5916\u5f88\u706b\uff0c\u5728\u56fd\u5185\u53d1\u5c55\u7684\u4e0d\u5982 MySQL\uff0c\u4f46\u4e5f\u6709\u4eba\u4f7f\u7528\u3002 \u8fd9\u4e24\u5e74 PostgreSQL  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[1995,1994,1913,429,1160],"class_list":["post-4451","post","type-post","status-publish","format-standard","hentry","category-sql","tag-cast","tag-mariadb","tag-mysqlhotcopy","tag-postgresql","tag-1160"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4451"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4451\/revisions"}],"predecessor-version":[{"id":4452,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4451\/revisions\/4452"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}