{"id":170091,"date":"2024-11-06T21:04:21","date_gmt":"2024-11-06T13:04:21","guid":{"rendered":"https:\/\/server.hk\/cnblog\/170091\/"},"modified":"2024-11-06T21:04:21","modified_gmt":"2024-11-06T13:04:21","slug":"%e5%b9%b4%e6%9c%ab%e4%b9%be%e8%b2%a8-oracle%e6%95%b8%e6%93%9a%e5%ba%ab%e5%b8%b8%e7%94%a8%e6%93%8d%e4%bd%9c%e8%aa%9e%e5%8f%a5%e5%a4%a7%e5%85%a8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/170091\/","title":{"rendered":"\u5e74\u672b\u4e7e\u8ca8 | Oracle\u6578\u64da\u5eab\u5e38\u7528\u64cd\u4f5c\u8a9e\u53e5\u5927\u5168"},"content":{"rendered":"<h1 id=\"%e5%b9%b4%e6%9c%ab%e4%b9%be%e8%b2%a8-oracle%e6%95%b8%e6%93%9a%e5%ba%ab%e5%b8%b8%e7%94%a8%e6%93%8d%e4%bd%9c%e8%aa%9e%e5%8f%a5%e5%a4%a7%e5%85%a8-TCUyriRrwM\">\u5e74\u672b\u4e7e\u8ca8 | Oracle\u6578\u64da\u5eab\u5e38\u7528\u64cd\u4f5c\u8a9e\u53e5\u5927\u5168<\/h1>\n<p>\u5728\u6578\u64da\u5eab\u7ba1\u7406\u4e2d\uff0cOracle\u6578\u64da\u5eab\u56e0\u5176\u5f37\u5927\u7684\u529f\u80fd\u548c\u7a69\u5b9a\u6027\u800c\u53d7\u5230\u5ee3\u6cdb\u4f7f\u7528\u3002\u7121\u8ad6\u662f\u6578\u64da\u7684\u67e5\u8a62\u3001\u66f4\u65b0\u9084\u662f\u7ba1\u7406\uff0c\u719f\u6089\u5e38\u7528\u7684\u64cd\u4f5c\u8a9e\u53e5\u5c0d\u65bc\u6578\u64da\u5eab\u7ba1\u7406\u54e1\u548c\u958b\u767c\u8005\u4f86\u8aaa\u90fd\u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u4e00\u4e9bOracle\u6578\u64da\u5eab\u7684\u5e38\u7528\u64cd\u4f5c\u8a9e\u53e5\uff0c\u5e6b\u52a9\u8b80\u8005\u66f4\u6709\u6548\u5730\u9032\u884c\u6578\u64da\u64cd\u4f5c\u3002<\/p>\n<h2 id=\"1-%e5%9f%ba%e6%9c%ac%e6%9f%a5%e8%a9%a2%e8%aa%9e%e5%8f%a5-TCUyriRrwM\">1. \u57fa\u672c\u67e5\u8a62\u8a9e\u53e5<\/h2>\n<p>\u67e5\u8a62\u6578\u64da\u662f\u6578\u64da\u5eab\u64cd\u4f5c\u4e2d\u6700\u57fa\u672c\u7684\u529f\u80fd\u3002\u4f7f\u7528SELECT\u8a9e\u53e5\u53ef\u4ee5\u5f9e\u6578\u64da\u8868\u4e2d\u6aa2\u7d22\u6578\u64da\u3002<\/p>\n<pre><code>SELECT column1, column2 FROM table_name WHERE condition;<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u82e5\u8981\u67e5\u8a62\u54e1\u5de5\u8868\u4e2d\u6240\u6709\u54e1\u5de5\u7684\u59d3\u540d\u548c\u5de5\u8cc7\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8a9e\u53e5\uff1a<\/p>\n<pre><code>SELECT name, salary FROM employees;<\/code><\/pre>\n<h2 id=\"2-%e6%8f%92%e5%85%a5%e6%95%b8%e6%93%9a-TCUyriRrwM\">2. \u63d2\u5165\u6578\u64da<\/h2>\n<p>\u8981\u5411\u6578\u64da\u8868\u4e2d\u63d2\u5165\u65b0\u6578\u64da\uff0c\u53ef\u4ee5\u4f7f\u7528INSERT\u8a9e\u53e5\u3002<\/p>\n<pre><code>INSERT INTO table_name (column1, column2) VALUES (value1, value2);<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u5411\u54e1\u5de5\u8868\u4e2d\u63d2\u5165\u4e00\u540d\u65b0\u54e1\u5de5\u7684\u6578\u64da\uff1a<\/p>\n<pre><code>INSERT INTO employees (name, salary) VALUES ('John Doe', 50000);<\/code><\/pre>\n<h2 id=\"3-%e6%9b%b4%e6%96%b0%e6%95%b8%e6%93%9a-TCUyriRrwM\">3. \u66f4\u65b0\u6578\u64da<\/h2>\n<p>\u66f4\u65b0\u5df2\u5b58\u5728\u7684\u6578\u64da\u53ef\u4ee5\u4f7f\u7528UPDATE\u8a9e\u53e5\u3002<\/p>\n<pre><code>UPDATE table_name SET column1 = value1 WHERE condition;<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u5c07\u54e1\u5de5John Doe\u7684\u5de5\u8cc7\u66f4\u65b0\u70ba55000\uff1a<\/p>\n<pre><code>UPDATE employees SET salary = 55000 WHERE name = 'John Doe';<\/code><\/pre>\n<h2 id=\"4-%e5%88%aa%e9%99%a4%e6%95%b8%e6%93%9a-TCUyriRrwM\">4. \u522a\u9664\u6578\u64da<\/h2>\n<p>\u8981\u522a\u9664\u6578\u64da\u8868\u4e2d\u7684\u6578\u64da\uff0c\u53ef\u4ee5\u4f7f\u7528DELETE\u8a9e\u53e5\u3002<\/p>\n<pre><code>DELETE FROM table_name WHERE condition;<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u522a\u9664\u540d\u70baJohn Doe\u7684\u54e1\u5de5\u8a18\u9304\uff1a<\/p>\n<pre><code>DELETE FROM employees WHERE name = 'John Doe';<\/code><\/pre>\n<h2 id=\"5-%e6%95%b8%e6%93%9a%e8%a1%a8%e7%9a%84%e5%89%b5%e5%bb%ba%e8%88%87%e4%bf%ae%e6%94%b9-TCUyriRrwM\">5. \u6578\u64da\u8868\u7684\u5275\u5efa\u8207\u4fee\u6539<\/h2>\n<p>\u5275\u5efa\u65b0\u6578\u64da\u8868\u53ef\u4ee5\u4f7f\u7528CREATE TABLE\u8a9e\u53e5\u3002<\/p>\n<pre><code>CREATE TABLE table_name (\n    column1 datatype,\n    column2 datatype,\n    ...\n);<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u5275\u5efa\u4e00\u500b\u65b0\u7684\u54e1\u5de5\u8868\uff1a<\/p>\n<pre><code>CREATE TABLE employees (\n    id NUMBER PRIMARY KEY,\n    name VARCHAR2(100),\n    salary NUMBER\n);<\/code><\/pre>\n<p>\u82e5\u8981\u4fee\u6539\u5df2\u5b58\u5728\u7684\u6578\u64da\u8868\u7d50\u69cb\uff0c\u53ef\u4ee5\u4f7f\u7528ALTER TABLE\u8a9e\u53e5\u3002<\/p>\n<pre><code>ALTER TABLE table_name ADD column_name datatype;<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u5411\u54e1\u5de5\u8868\u4e2d\u6dfb\u52a0\u4e00\u500b\u65b0\u7684\u5217\u4ee5\u5b58\u5132\u54e1\u5de5\u7684\u96fb\u5b50\u90f5\u4ef6\uff1a<\/p>\n<pre><code>ALTER TABLE employees ADD email VARCHAR2(100);<\/code><\/pre>\n<h2 id=\"6-%e6%95%b8%e6%93%9a%e8%a1%a8%e7%9a%84%e5%88%aa%e9%99%a4-TCUyriRrwM\">6. \u6578\u64da\u8868\u7684\u522a\u9664<\/h2>\n<p>\u8981\u522a\u9664\u6578\u64da\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528DROP TABLE\u8a9e\u53e5\u3002<\/p>\n<pre><code>DROP TABLE table_name;<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u522a\u9664\u54e1\u5de5\u8868\uff1a<\/p>\n<pre><code>DROP TABLE employees;<\/code><\/pre>\n<h2 id=\"7-%e6%95%b8%e6%93%9a%e7%9a%84%e6%8e%92%e5%ba%8f%e8%88%87%e5%88%86%e7%b5%84-TCUyriRrwM\">7. \u6578\u64da\u7684\u6392\u5e8f\u8207\u5206\u7d44<\/h2>\n<p>\u4f7f\u7528ORDER BY\u5b50\u53e5\u53ef\u4ee5\u5c0d\u67e5\u8a62\u7d50\u679c\u9032\u884c\u6392\u5e8f\u3002<\/p>\n<pre><code>SELECT column1, column2 FROM table_name ORDER BY column1 ASC|DESC;<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u6309\u5de5\u8cc7\u964d\u5e8f\u6392\u5217\u54e1\u5de5\uff1a<\/p>\n<pre><code>SELECT name, salary FROM employees ORDER BY salary DESC;<\/code><\/pre>\n<p>\u4f7f\u7528GROUP BY\u5b50\u53e5\u53ef\u4ee5\u5c0d\u67e5\u8a62\u7d50\u679c\u9032\u884c\u5206\u7d44\u3002<\/p>\n<pre><code>SELECT column1, COUNT(*) FROM table_name GROUP BY column1;<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u7d71\u8a08\u6bcf\u500b\u5de5\u8cc7\u7d1a\u5225\u7684\u54e1\u5de5\u6578\u91cf\uff1a<\/p>\n<pre><code>SELECT salary, COUNT(*) FROM employees GROUP BY salary;<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-TCUyriRrwM\">\u7e3d\u7d50<\/h2>\n<p>\u638c\u63e1Oracle\u6578\u64da\u5eab\u7684\u5e38\u7528\u64cd\u4f5c\u8a9e\u53e5\u5c0d\u65bc\u6578\u64da\u5eab\u7ba1\u7406\u548c\u958b\u767c\u81f3\u95dc\u91cd\u8981\u3002\u672c\u6587\u4ecb\u7d39\u7684\u57fa\u672c\u8a9e\u53e5\u6db5\u84cb\u4e86\u67e5\u8a62\u3001\u63d2\u5165\u3001\u66f4\u65b0\u3001\u522a\u9664\u7b49\u5e38\u898b\u64cd\u4f5c\uff0c\u5e6b\u52a9\u8b80\u8005\u5728\u65e5\u5e38\u5de5\u4f5c\u4e2d\u63d0\u9ad8\u6548\u7387\u3002\u82e5\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u6578\u64da\u7ba1\u7406\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\u4f86\u652f\u6301\u60a8\u7684\u6578\u64da\u5eab\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u5e74\u672b\u4e7e\u8ca8\uff0c\u638c\u63e1Oracle\u6578\u64da\u5eab\u5e38\u7528\u64cd\u4f5c\u8a9e\u53e5\u5927\u5168\uff0c\u63d0\u5347\u6578\u64da\u7ba1\u7406\u6548\u7387\uff0c\u52a9\u529b\u5c08\u696d\u6280\u80fd\u63d0\u5347\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-170091","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/170091","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=170091"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/170091\/revisions"}],"predecessor-version":[{"id":170092,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/170091\/revisions\/170092"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=170091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=170091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=170091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}