{"id":162403,"date":"2024-11-04T14:48:20","date_gmt":"2024-11-04T06:48:20","guid":{"rendered":"https:\/\/server.hk\/cnblog\/162403\/"},"modified":"2024-11-04T14:48:20","modified_gmt":"2024-11-04T06:48:20","slug":"%e7%b0%a1%e5%96%ae%e6%98%93%e6%87%82%ef%bc%81%e5%bf%ab%e9%80%9f%e4%b8%8a%e6%89%8b-postgresql%ef%bc%9a%e6%8e%8c%e6%8f%a1-psql-%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%b7%a5%e5%85%b7%e9%80%a3%e6%8e%a5%e6%8a%80","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/162403\/","title":{"rendered":"\u7c21\u55ae\u6613\u61c2\uff01\u5feb\u901f\u4e0a\u624b PostgreSQL\uff1a\u638c\u63e1 PSQL \u547d\u4ee4\u884c\u5de5\u5177\u9023\u63a5\u6280\u5de7"},"content":{"rendered":"<h1 id=\"%e7%b0%a1%e5%96%ae%e6%98%93%e6%87%82%ef%bc%81%e5%bf%ab%e9%80%9f%e4%b8%8a%e6%89%8b-postgresql%ef%bc%9a%e6%8e%8c%e6%8f%a1-psql-%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%b7%a5%e5%85%b7%e9%80%a3%e6%8e%a5%e6%8a%80-oadHBSXuMt\">\u7c21\u55ae\u6613\u61c2\uff01\u5feb\u901f\u4e0a\u624b PostgreSQL\uff1a\u638c\u63e1 PSQL \u547d\u4ee4\u884c\u5de5\u5177\u9023\u63a5\u6280\u5de7<\/h1>\n<p>PostgreSQL \u662f\u4e00\u500b\u529f\u80fd\u5f37\u5927\u7684\u958b\u6e90\u95dc\u806f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u7a0b\u5e8f\u4e2d\u3002\u7121\u8ad6\u662f\u5c0f\u578b\u9805\u76ee\u9084\u662f\u5927\u578b\u4f01\u696d\u61c9\u7528\uff0cPostgreSQL \u90fd\u80fd\u63d0\u4f9b\u7a69\u5b9a\u7684\u6027\u80fd\u548c\u9748\u6d3b\u7684\u64f4\u5c55\u6027\u3002\u5728\u9019\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5011\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528 PSQL \u547d\u4ee4\u884c\u5de5\u5177\u5feb\u901f\u9023\u63a5\u5230 PostgreSQL \u6578\u64da\u5eab\uff0c\u4e26\u638c\u63e1\u4e00\u4e9b\u57fa\u672c\u7684\u64cd\u4f5c\u6280\u5de7\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-psql%ef%bc%9f-oadHBSXuMt\">\u4ec0\u9ebc\u662f PSQL\uff1f<\/h2>\n<p>PSQL \u662f PostgreSQL \u7684\u547d\u4ee4\u884c\u754c\u9762\u5de5\u5177\uff0c\u5141\u8a31\u7528\u6236\u76f4\u63a5\u8207\u6578\u64da\u5eab\u9032\u884c\u4ea4\u4e92\u3002\u901a\u904e PSQL\uff0c\u7528\u6236\u53ef\u4ee5\u57f7\u884c SQL \u67e5\u8a62\u3001\u7ba1\u7406\u6578\u64da\u5eab\u5c0d\u8c61\u3001\u4ee5\u53ca\u9032\u884c\u6578\u64da\u5eab\u7684\u7dad\u8b77\u5de5\u4f5c\u3002PSQL \u63d0\u4f9b\u4e86\u4e00\u500b\u76f4\u89c0\u7684\u754c\u9762\uff0c\u9069\u5408\u958b\u767c\u8005\u548c\u6578\u64da\u5eab\u7ba1\u7406\u54e1\u4f7f\u7528\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-postgresql-%e5%92%8c-psql-oadHBSXuMt\">\u5b89\u88dd PostgreSQL \u548c PSQL<\/h2>\n<p>\u5728\u4f7f\u7528 PSQL \u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88dd PostgreSQL\u3002\u5b89\u88dd\u904e\u7a0b\u56e0\u64cd\u4f5c\u7cfb\u7d71\u800c\u7570\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7cfb\u7d71\u7684\u5b89\u88dd\u6b65\u9a5f\uff1a<\/p>\n<ul>\n<li><strong>\u5728 Ubuntu \u4e0a\u5b89\u88dd\uff1a<\/strong>\n<pre><code>sudo apt update\nsudo apt install postgresql postgresql-contrib<\/code><\/pre>\n<\/li>\n<li><strong>\u5728 CentOS \u4e0a\u5b89\u88dd\uff1a<\/strong>\n<pre><code>sudo yum install postgresql-server postgresql-contrib<\/code><\/pre>\n<\/li>\n<li><strong>\u5728 Windows \u4e0a\u5b89\u88dd\uff1a<\/strong>\n<p>\u53ef\u4ee5\u5f9e PostgreSQL \u7684\u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u5b89\u88dd\u5305\uff0c\u4e26\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88dd\u3002<\/p>\n<\/li>\n<\/ul>\n<h2 id=\"%e9%80%a3%e6%8e%a5%e5%88%b0-postgresql-%e6%95%b8%e6%93%9a%e5%ba%ab-oadHBSXuMt\">\u9023\u63a5\u5230 PostgreSQL \u6578\u64da\u5eab<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528 PSQL \u9023\u63a5\u5230 PostgreSQL \u6578\u64da\u5eab\u3002\u57fa\u672c\u7684\u9023\u63a5\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre><code>psql -h \u4e3b\u6a5f\u540d -U \u7528\u6236\u540d -d \u6578\u64da\u5eab\u540d<\/code><\/pre>\n<p>\u5176\u4e2d\uff0c<strong>\u4e3b\u6a5f\u540d<\/strong> \u662f\u6578\u64da\u5eab\u6240\u5728\u7684\u4f3a\u670d\u5668\u5730\u5740\uff0c<strong>\u7528\u6236\u540d<\/strong> \u662f\u7528\u65bc\u767b\u9304\u7684\u7528\u6236\u540d\uff0c<strong>\u6578\u64da\u5eab\u540d<\/strong> \u662f\u8981\u9023\u63a5\u7684\u6578\u64da\u5eab\u540d\u7a31\u3002\u5982\u679c\u6578\u64da\u5eab\u5728\u672c\u5730\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>localhost<\/code> \u4f5c\u70ba\u4e3b\u6a5f\u540d\u3002<\/p>\n<h3 id=\"%e7%a4%ba%e4%be%8b-oadHBSXuMt\">\u793a\u4f8b<\/h3>\n<p>\u5047\u8a2d\u6211\u5011\u8981\u9023\u63a5\u5230\u672c\u5730\u7684 PostgreSQL \u6578\u64da\u5eab\uff0c\u4f7f\u7528\u7684\u7528\u6236\u540d\u70ba <code>postgres<\/code>\uff0c\u6578\u64da\u5eab\u540d\u70ba <code>mydb<\/code>\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>psql -h localhost -U postgres -d mydb<\/code><\/pre>\n<p>\u57f7\u884c\u547d\u4ee4\u5f8c\uff0c\u7cfb\u7d71\u6703\u63d0\u793a\u8f38\u5165\u5bc6\u78bc\uff0c\u8f38\u5165\u6b63\u78ba\u7684\u5bc6\u78bc\u5f8c\u5373\u53ef\u6210\u529f\u9023\u63a5\u5230\u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"%e5%9f%ba%e6%9c%ac%e7%9a%84-psql-%e5%91%bd%e4%bb%a4-oadHBSXuMt\">\u57fa\u672c\u7684 PSQL \u547d\u4ee4<\/h2>\n<p>\u9023\u63a5\u6210\u529f\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u57fa\u672c\u7684 PSQL \u547d\u4ee4\u4f86\u64cd\u4f5c\u6578\u64da\u5eab\uff1a<\/p>\n<ul>\n<li><strong>\u67e5\u770b\u7576\u524d\u6578\u64da\u5eab\uff1a<\/strong>\n<pre><code>c<\/code><\/pre>\n<\/li>\n<li><strong>\u5217\u51fa\u6240\u6709\u6578\u64da\u5eab\uff1a<\/strong>\n<pre><code>l<\/code><\/pre>\n<\/li>\n<li><strong>\u5217\u51fa\u7576\u524d\u6578\u64da\u5eab\u4e2d\u7684\u6240\u6709\u8868\uff1a<\/strong>\n<pre><code>dt<\/code><\/pre>\n<\/li>\n<li><strong>\u67e5\u770b\u8868\u7d50\u69cb\uff1a<\/strong>\n<pre><code>d \u8868\u540d<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2 id=\"%e9%80%80%e5%87%ba-psql-oadHBSXuMt\">\u9000\u51fa PSQL<\/h2>\n<p>\u5b8c\u6210\u64cd\u4f5c\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa PSQL\uff1a<\/p>\n<pre><code>q<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-oadHBSXuMt\">\u7e3d\u7d50<\/h2>\n<p>\u638c\u63e1 PSQL \u547d\u4ee4\u884c\u5de5\u5177\u7684\u57fa\u672c\u9023\u63a5\u6280\u5de7\u548c\u64cd\u4f5c\u547d\u4ee4\uff0c\u53ef\u4ee5\u5e6b\u52a9\u7528\u6236\u66f4\u9ad8\u6548\u5730\u7ba1\u7406 PostgreSQL \u6578\u64da\u5eab\u3002\u7121\u8ad6\u662f\u958b\u767c\u9084\u662f\u7dad\u8b77\uff0c\u719f\u6089\u9019\u4e9b\u57fa\u672c\u64cd\u4f5c\u90fd\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u82e5\u60a8\u9700\u8981\u7a69\u5b9a\u7684\u6578\u64da\u5eab\u74b0\u5883\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u670d\u52d9\uff0c\u70ba\u60a8\u7684\u61c9\u7528\u63d0\u4f9b\u5f37\u5927\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u638c\u63e1 PostgreSQL \u7684 PSQL \u547d\u4ee4\u884c\u5de5\u5177\uff0c\u5b78\u7fd2\u7c21\u55ae\u6613\u61c2\u7684\u9023\u63a5\u6280\u5de7\uff0c\u5feb\u901f\u4e0a\u624b\u6578\u64da\u5eab\u7ba1\u7406\uff0c\u63d0\u5347\u5de5\u4f5c\u6548\u7387\uff01<\/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-162403","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/162403","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=162403"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/162403\/revisions"}],"predecessor-version":[{"id":162404,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/162403\/revisions\/162404"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=162403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=162403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=162403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}