{"id":736,"date":"2025-07-24T18:45:15","date_gmt":"2025-07-24T10:45:15","guid":{"rendered":"https:\/\/www.hgfwq.com\/blog\/?p=736"},"modified":"2025-07-24T18:45:15","modified_gmt":"2025-07-24T10:45:15","slug":"postgres-%e6%9f%a5%e7%9c%8b%e6%89%80%e6%9c%89%e6%95%b0%e6%8d%ae%e5%ba%93%e4%b8%ba%e4%bb%80%e4%b9%88%e5%a6%82%e6%ad%a4%e7%ae%80%e5%8d%95%e4%b8%94%e9%ab%98%e6%95%88","status":"publish","type":"post","link":"https:\/\/www.hgfwq.com\/blog\/736.html","title":{"rendered":"Postgres \u67e5\u770b\u6240\u6709\u6570\u636e\u5e93\u4e3a\u4ec0\u4e48\u5982\u6b64\u7b80\u5355\u4e14\u9ad8\u6548"},"content":{"rendered":"<p><h3>\u7cbe\u534e\u6458\u8981<\/h3>\n<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.hgfwq.com\/blog\/wp-content\/uploads\/2025\/07\/Vcl297r.jpg\" alt=\"Postgres \u67e5\u770b\u6240\u6709\u6570\u636e\u5e93\u4e3a\u4ec0\u4e48\u5982\u6b64\u7b80\u5355\u4e14\u9ad8\u6548\" title=\"Postgres \u67e5\u770b\u6240\u6709\u6570\u636e\u5e93\u4e3a\u4ec0\u4e48\u5982\u6b64\u7b80\u5355\u4e14\u9ad8\u6548\"><\/p>\n<p><p>\u60f3\u8981\u5728PostgreSQL\u4e2d\u67e5\u770b\u6240\u6709\u6570\u636e\u5e93\uff0c\u53ea\u9700\u6267\u884c\u4e00\u6761\u7b80\u5355\u7684SQL\u547d\u4ee4\u5373\u53ef\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e00\u8fc7\u7a0b\uff0c\u5e76\u9644\u5e26\u4e00\u4e9b\u5b9e\u7528\u7684\u64cd\u4f5c\u6280\u5de7\u3002<\/p>\n<\/p>\n<p><h3>\u51c6\u5907\u5de5\u4f5c<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\u5b89\u88c5\u4e86PostgreSQL\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u5e76\u4e14\u6709\u4e00\u4e2a\u6709\u6548\u7684\u6570\u636e\u5e93\u7528\u6237\u6743\u9650\u3002\u4ee5\u4e0b\u662f\u5728PostgreSQL\u4e2d\u67e5\u770b\u6240\u6709\u6570\u636e\u5e93\u7684\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><h3>\u6267\u884cSQL\u547d\u4ee4<\/h3>\n<\/p>\n<p><p>\u8981\u67e5\u770bPostgreSQL\u4e2d\u7684\u6240\u6709\u6570\u636e\u5e93\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bSQL\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre>SELECT datname FROM pg_database;<\/pre>\n<\/p>\n<p><p>\u8fd9\u6761\u547d\u4ee4\u5c06\u4ece`pg_database`\u7cfb\u7edf\u8868\u4e2d\u68c0\u7d22\u6240\u6709\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002\u6267\u884c\u8fd9\u6761\u547d\u4ee4\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4e00\u4e2a\u5305\u542b\u6240\u6709\u6570\u636e\u5e93\u540d\u79f0\u7684\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h3>\u8fde\u63a5\u5230PostgreSQL\u670d\u52a1\u5668<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u901a\u8fc7\u547d\u4ee4\u884c\u5de5\u5177\uff08\u5982psql\uff09\u8fde\u63a5\u5230PostgreSQL\u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u5de5\u5177\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u8fde\u63a5\u5230PostgreSQL\u670d\u52a1\u5668\uff1a<\/li>\n<\/ul>\n<p><pre>psql -U \u7528\u6237\u540d -h \u4e3b\u673a\u540d -p \u7aef\u53e3\u53f7<\/pre>\n<\/p>\n<ul>\n<li>\u5176\u4e2d\uff0c\u7528\u6237\u540d\u3001\u4e3b\u673a\u540d\u548c\u7aef\u53e3\u53f7\u5e94\u6839\u636e\u60a8\u7684\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u66ff\u6362\u3002<\/li>\n<\/ul>\n<p><h3>\u6267\u884cSQL\u67e5\u8be2<\/h3>\n<\/p>\n<p><p>\u8fde\u63a5\u5230\u670d\u52a1\u5668\u540e\uff0c\u8f93\u5165\u4ee5\u4e0bSQL\u547d\u4ee4\u6765\u67e5\u770b\u6240\u6709\u6570\u636e\u5e93\uff1a<\/p>\n<\/p>\n<p><pre>SELECT datname FROM pg_database;<\/pre>\n<\/p>\n<p><p>\u6267\u884c\u8fd9\u6761\u547d\u4ee4\u540e\uff0c\u60a8\u5c06\u770b\u5230\u5f53\u524dPostgreSQL\u670d\u52a1\u5668\u4e2d\u6240\u6709\u7684\u6570\u636e\u5e93\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h3>\u5e38\u89c1\u95ee\u9898\u89e3\u7b54<\/h3>\n<\/p>\n<p><h3><b>\u5982\u4f55\u786e\u5b9aPostgreSQL\u670d\u52a1\u5668\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff1f<\/b><\/h3>\n<\/p>\n<p><p>\u901a\u5e38\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\u5728PostgreSQL\u670d\u52a1\u5668\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e\uff0c\u6216\u8005\u60a8\u53ef\u4ee5\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u521b\u5efa\u3002\u5982\u679c\u4e0d\u786e\u5b9a\uff0c\u53ef\u4ee5\u67e5\u9605\u670d\u52a1\u5668\u6587\u6863\u6216\u8054\u7cfb\u670d\u52a1\u5668\u7ba1\u7406\u5458\u3002<\/p>\n<\/p>\n<p><h3><b>\u5982\u4f55\u66f4\u6539\u6570\u636e\u5e93\u7684\u8fde\u63a5\u53c2\u6570\uff08\u5982\u4e3b\u673a\u540d\u3001\u7aef\u53e3\u53f7\uff09\uff1f<\/b><\/h3>\n<\/p>\n<p><p>\u66f4\u6539\u8fde\u63a5\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539psql\u547d\u4ee4\u4e2d\u7684\u53c2\u6570\u6765\u5b9e\u73b0\u3002\u4f8b\u5982\uff0c\u8981\u5c06\u4e3b\u673a\u540d\u4ece&#8221;localhost&#8221;\u66f4\u6539\u4e3a&#8221;192.168.1.1&#8243;\uff0c\u7aef\u53e3\u53f7\u4ece&#8221;5432&#8243;\u66f4\u6539\u4e3a&#8221;5433&#8243;\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre>psql -U \u7528\u6237\u540d -h 192.168.1.1 -p 5433<\/pre>\n<\/p>\n<p><h3><b>\u5982\u4f55\u67e5\u770b\u7279\u5b9a\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u8868\uff1f<\/b><\/h3>\n<\/p>\n<p><p>\u8981\u67e5\u770b\u7279\u5b9a\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u8868\uff0c\u9996\u5148\u9700\u8981\u8fde\u63a5\u5230\u8be5\u6570\u636e\u5e93\uff0c\u7136\u540e\u6267\u884c\u4ee5\u4e0bSQL\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre>SELECT tablename FROM pg_tables WHERE schemaname = 'public';<\/pre>\n<\/p>\n<p><p>\u8fd9\u6761\u547d\u4ee4\u5c06\u5217\u51fa\u6570\u636e\u5e93\u4e2d\u540d\u4e3a&#8221;public&#8221;\u6a21\u5f0f\u7684\u8868\u3002\u60a8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u66f4\u6539\u6a21\u5f0f\u540d\u79f0\u3002<\/p>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u6267\u884c\u7b80\u5355\u7684SQL\u547d\u4ee4\uff0c\u60a8\u53ef\u4ee5\u5728PostgreSQL\u4e2d\u8f7b\u677e\u67e5\u770b\u6240\u6709\u6570\u636e\u5e93\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u67e5\u770b\u6240\u6709\u6570\u636e\u5e93\u7684\u65b9\u6cd5\uff0c\u5e76\u56de\u7b54\u4e86\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002\u5982\u679c\u60a8\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u9047\u5230\u4efb\u4f55\u56f0\u96be\uff0c\u53ef\u4ee5\u67e5\u9605\u76f8\u5173\u6587\u6863\u6216\u5bfb\u6c42\u4e13\u4e1a\u5e2e\u52a9\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7cbe\u534e\u6458\u8981 \u60f3\u8981\u5728PostgreSQL\u4e2d\u67e5\u770b\u6240\u6709\u6570\u636e\u5e93\uff0c\u53ea\u9700\u6267\u884c\u4e00\u6761\u7b80\u5355\u7684SQL\u547d\u4ee4\u5373\u53ef\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e00\u8fc7\u7a0b\uff0c\u5e76\u9644\u5e26\u4e00\u4e9b\u5b9e\u7528\u7684\u64cd\u4f5c\u6280\u5de7\u3002 \u51c6\u5907\u5de5\u4f5c \u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\u5b89\u88c5\u4e86PostgreSQL\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u5e76\u4e14\u6709\u4e00\u4e2a\u6709\u6548\u7684\u6570\u636e\u5e93\u7528\u6237&#8230;<\/p>\n","protected":false},"author":1,"featured_media":737,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[337,338,160],"topic":[],"class_list":["post-736","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-haiwai","tag-postgresql","tag-sql","tag-160"],"_links":{"self":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/comments?post=736"}],"version-history":[{"count":1,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/736\/revisions"}],"predecessor-version":[{"id":739,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/736\/revisions\/739"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media\/737"}],"wp:attachment":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media?parent=736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/categories?post=736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/tags?post=736"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/topic?post=736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}