{"id":160669,"date":"2024-11-04T00:01:27","date_gmt":"2024-11-03T16:01:27","guid":{"rendered":"https:\/\/server.hk\/cnblog\/160669\/"},"modified":"2024-11-04T00:01:28","modified_gmt":"2024-11-03T16:01:28","slug":"postgresql%e6%95%99%e7%a8%8bpostgresql-%e8%aa%9e%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/160669\/","title":{"rendered":"POSTGRESQL\u6559\u7a0bPostgreSQL \u8a9e\u6cd5"},"content":{"rendered":"<h1 id=\"postgresql%e6%95%99%e7%a8%8b%ef%bc%9apostgresql%e8%aa%9e%e6%b3%95-fhhBkfeIoS\">PostgreSQL\u6559\u7a0b\uff1aPostgreSQL\u8a9e\u6cd5<\/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\u5b83\u652f\u6301\u591a\u7a2e\u6578\u64da\u985e\u578b\u548c\u8907\u96dc\u7684\u67e5\u8a62\uff0c\u4e26\u4e14\u5177\u6709\u9ad8\u64f4\u5c55\u6027\u548c\u53ef\u9760\u6027\u3002\u672c\u6587\u5c07\u4ecb\u7d39PostgreSQL\u7684\u57fa\u672c\u8a9e\u6cd5\uff0c\u5e6b\u52a9\u8b80\u8005\u66f4\u597d\u5730\u7406\u89e3\u548c\u4f7f\u7528\u9019\u500b\u6578\u64da\u5eab\u7cfb\u7d71\u3002<\/p>\n<h2 id=\"%e5%9f%ba%e6%9c%ac%e6%a6%82%e5%bf%b5-fhhBkfeIoS\">\u57fa\u672c\u6982\u5ff5<\/h2>\n<p>\u5728\u6df1\u5165\u8a9e\u6cd5\u4e4b\u524d\uff0c\u4e86\u89e3\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002PostgreSQL\u4f7f\u7528\u8868\u683c\u4f86\u5b58\u5132\u6578\u64da\uff0c\u6bcf\u500b\u8868\u683c\u7531\u884c\u548c\u5217\u7d44\u6210\u3002\u884c\u4ee3\u8868\u6578\u64da\u8a18\u9304\uff0c\u800c\u5217\u5247\u4ee3\u8868\u6578\u64da\u7684\u5c6c\u6027\u3002<\/p>\n<h2 id=\"%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b-fhhBkfeIoS\">\u6578\u64da\u985e\u578b<\/h2>\n<p>PostgreSQL\u652f\u6301\u591a\u7a2e\u6578\u64da\u985e\u578b\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u6574\u6578\u985e\u578b\uff1a<\/strong>\u5982 <code>INTEGER<\/code>\u3001<code>SMALLINT<\/code>\u3001<code>BIGINT<\/code><\/li>\n<li><strong>\u6d6e\u9ede\u6578\u985e\u578b\uff1a<\/strong>\u5982 <code>REAL<\/code>\u3001<code>DOUBLE PRECISION<\/code><\/li>\n<li><strong>\u5b57\u7b26\u985e\u578b\uff1a<\/strong>\u5982 <code>CHAR<\/code>\u3001<code>VARCHAR<\/code>\u3001<code>TEXT<\/code><\/li>\n<li><strong>\u65e5\u671f\u548c\u6642\u9593\u985e\u578b\uff1a<\/strong>\u5982 <code>DATE<\/code>\u3001<code>TIME<\/code>\u3001<code>TIMESTAMP<\/code><\/li>\n<li><strong>\u5e03\u723e\u985e\u578b\uff1a<\/strong>\u5982 <code>BOOLEAN<\/code><\/li>\n<\/ul>\n<h2 id=\"%e5%9f%ba%e6%9c%ac%e8%aa%9e%e6%b3%95-fhhBkfeIoS\">\u57fa\u672c\u8a9e\u6cd5<\/h2>\n<h3 id=\"%e5%89%b5%e5%bb%ba%e6%95%b8%e6%93%9a%e5%ba%ab-fhhBkfeIoS\">\u5275\u5efa\u6578\u64da\u5eab<\/h3>\n<p>\u8981\u5275\u5efa\u4e00\u500b\u65b0\u7684\u6578\u64da\u5eab\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8a9e\u6cd5\uff1a<\/p>\n<pre><code>CREATE DATABASE database_name;<\/code><\/pre>\n<h3 id=\"%e5%89%b5%e5%bb%ba%e8%a1%a8%e6%a0%bc-fhhBkfeIoS\">\u5275\u5efa\u8868\u683c<\/h3>\n<p>\u5275\u5efa\u8868\u683c\u7684\u8a9e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>CREATE TABLE table_name (\n    column1 datatype,\n    column2 datatype,\n    column3 datatype\n);<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u5275\u5efa\u4e00\u500b\u7528\u6236\u8868\u683c\uff1a<\/p>\n<pre><code>CREATE TABLE users (\n    id SERIAL PRIMARY KEY,\n    username VARCHAR(50) NOT NULL,\n    email VARCHAR(100) NOT NULL,\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);<\/code><\/pre>\n<h3 id=\"%e6%8f%92%e5%85%a5%e6%95%b8%e6%93%9a-fhhBkfeIoS\">\u63d2\u5165\u6578\u64da<\/h3>\n<p>\u63d2\u5165\u6578\u64da\u7684\u8a9e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>INSERT INTO table_name (column1, column2) VALUES (value1, value2);<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u5411\u7528\u6236\u8868\u683c\u4e2d\u63d2\u5165\u4e00\u689d\u8a18\u9304\uff1a<\/p>\n<pre><code>INSERT INTO users (username, email) VALUES ('john_doe', 'john@example.com');<\/code><\/pre>\n<h3 id=\"%e6%9f%a5%e8%a9%a2%e6%95%b8%e6%93%9a-fhhBkfeIoS\">\u67e5\u8a62\u6578\u64da<\/h3>\n<p>\u67e5\u8a62\u6578\u64da\u7684\u57fa\u672c\u8a9e\u6cd5\u70ba\uff1a<\/p>\n<pre><code>SELECT column1, column2 FROM table_name WHERE condition;<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u67e5\u8a62\u6240\u6709\u7528\u6236\u7684\u96fb\u5b50\u90f5\u4ef6\uff1a<\/p>\n<pre><code>SELECT email FROM users;<\/code><\/pre>\n<h3 id=\"%e6%9b%b4%e6%96%b0%e6%95%b8%e6%93%9a-fhhBkfeIoS\">\u66f4\u65b0\u6578\u64da<\/h3>\n<p>\u66f4\u65b0\u6578\u64da\u7684\u8a9e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>UPDATE table_name SET column1 = value1 WHERE condition;<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u66f4\u65b0\u7528\u6236\u7684\u96fb\u5b50\u90f5\u4ef6\uff1a<\/p>\n<pre><code>UPDATE users SET email = 'new_email@example.com' WHERE username = 'john_doe';<\/code><\/pre>\n<h3 id=\"%e5%88%aa%e9%99%a4%e6%95%b8%e6%93%9a-fhhBkfeIoS\">\u522a\u9664\u6578\u64da<\/h3>\n<p>\u522a\u9664\u6578\u64da\u7684\u8a9e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>DELETE FROM table_name WHERE condition;<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u522a\u9664\u4e00\u500b\u7528\u6236\uff1a<\/p>\n<pre><code>DELETE FROM users WHERE username = 'john_doe';<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-fhhBkfeIoS\">\u7e3d\u7d50<\/h2>\n<p>PostgreSQL\u662f\u4e00\u500b\u529f\u80fd\u5f37\u5927\u7684\u6578\u64da\u5eab\u7cfb\u7d71\uff0c\u64c1\u6709\u8c50\u5bcc\u7684\u8a9e\u6cd5\u548c\u529f\u80fd\u3002\u901a\u904e\u672c\u6587\u4ecb\u7d39\u7684\u57fa\u672c\u8a9e\u6cd5\uff0c\u60a8\u53ef\u4ee5\u958b\u59cb\u4f7f\u7528PostgreSQL\u9032\u884c\u6578\u64da\u7ba1\u7406\u3002\u7121\u8ad6\u662f\u5275\u5efa\u6578\u64da\u5eab\u3001\u8868\u683c\uff0c\u9084\u662f\u9032\u884c\u6578\u64da\u7684\u589e\u522a\u6539\u67e5\uff0cPostgreSQL\u90fd\u80fd\u63d0\u4f9b\u9748\u6d3b\u7684\u89e3\u6c7a\u65b9\u6848\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u4f86\u904b\u884c\u60a8\u7684PostgreSQL\u6578\u64da\u5eab\uff0c\u8acb\u8003\u616e\u6211\u5011\u7684\u670d\u52d9\uff0c\u8b93\u60a8\u7684\u6578\u64da\u7ba1\u7406\u66f4\u52a0\u9ad8\u6548\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2PostgreSQL\u7684\u57fa\u672c\u8a9e\u6cd5\u548c\u9032\u968e\u6280\u5de7\uff0c\u638c\u63e1\u6578\u64da\u5eab\u7ba1\u7406\u8207\u67e5\u8a62\uff0c\u63d0\u5347\u60a8\u7684\u6578\u64da\u8655\u7406\u80fd\u529b\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-160669","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160669","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=160669"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160669\/revisions"}],"predecessor-version":[{"id":160670,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160669\/revisions\/160670"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=160669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=160669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=160669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}