{"id":152935,"date":"2024-11-02T03:15:23","date_gmt":"2024-11-01T19:15:23","guid":{"rendered":"https:\/\/server.hk\/cnblog\/152935\/"},"modified":"2024-11-02T03:15:24","modified_gmt":"2024-11-01T19:15:24","slug":"%e5%88%9d%e5%ad%b8-oracle-%e5%ad%b8%e7%bf%92%e7%ad%86%e8%a8%98%e4%b9%8b-oracle-%e5%b8%b8%e8%a6%8b%e6%93%8d%e4%bd%9c%e7%b8%bd%e7%b5%90","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/152935\/","title":{"rendered":"\u521d\u5b78 Oracle \u5b78\u7fd2\u7b46\u8a18\u4e4b Oracle \u5e38\u898b\u64cd\u4f5c\u7e3d\u7d50"},"content":{"rendered":"<h1 id=\"%e5%88%9d%e5%ad%b8-oracle-%e5%ad%b8%e7%bf%92%e7%ad%86%e8%a8%98%e4%b9%8b-oracle-%e5%b8%b8%e8%a6%8b%e6%93%8d%e4%bd%9c%e7%b8%bd%e7%b5%90-PYeCKCzpKH\">\u521d\u5b78 Oracle \u5b78\u7fd2\u7b46\u8a18\u4e4b Oracle \u5e38\u898b\u64cd\u4f5c\u7e3d\u7d50<\/h1>\n<p>Oracle \u6578\u64da\u5eab\u662f\u4e00\u500b\u529f\u80fd\u5f37\u5927\u7684\u95dc\u806f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u4f01\u696d\u7d1a\u61c9\u7528\u4e2d\u3002\u5c0d\u65bc\u521d\u5b78\u8005\u4f86\u8aaa\uff0c\u638c\u63e1 Oracle \u7684\u57fa\u672c\u64cd\u4f5c\u662f\u5b78\u7fd2\u6578\u64da\u5eab\u7ba1\u7406\u7684\u7b2c\u4e00\u6b65\u3002\u672c\u6587\u5c07\u7e3d\u7d50\u4e00\u4e9b\u5e38\u898b\u7684 Oracle \u64cd\u4f5c\uff0c\u5e6b\u52a9\u521d\u5b78\u8005\u5feb\u901f\u4e0a\u624b\u3002<\/p>\n<h2 id=\"1-%e5%ae%89%e8%a3%9d-oracle-%e6%95%b8%e6%93%9a%e5%ba%ab-PYeCKCzpKH\">1. \u5b89\u88dd Oracle \u6578\u64da\u5eab<\/h2>\n<p>\u5728\u958b\u59cb\u4f7f\u7528 Oracle \u6578\u64da\u5eab\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88dd\u5b83\u3002Oracle \u63d0\u4f9b\u4e86\u591a\u7a2e\u7248\u672c\uff0c\u5305\u62ec\u514d\u8cbb\u7684 Oracle Database Express Edition (XE)\u3002\u5b89\u88dd\u904e\u7a0b\u4e2d\uff0c\u4f7f\u7528\u8005\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u78ba\u4fdd\u7cfb\u7d71\u6eff\u8db3\u5b89\u88dd\u8981\u6c42\uff0c\u5305\u62ec\u64cd\u4f5c\u7cfb\u7d71\u7248\u672c\u548c\u786c\u789f\u7a7a\u9593\u3002<\/li>\n<li>\u9078\u64c7\u5408\u9069\u7684\u5b89\u88dd\u985e\u578b\uff0c\u5982\u5178\u578b\u5b89\u88dd\u6216\u81ea\u5b9a\u7fa9\u5b89\u88dd\u3002<\/li>\n<li>\u8a2d\u7f6e\u6578\u64da\u5eab\u7684\u7ba1\u7406\u54e1\u5bc6\u78bc\uff0c\u4e26\u8a18\u4f4f\u8a72\u5bc6\u78bc\u4ee5\u4fbf\u5f8c\u7e8c\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<h2 id=\"2-%e9%80%a3%e6%8e%a5%e5%88%b0-oracle-%e6%95%b8%e6%93%9a%e5%ba%ab-PYeCKCzpKH\">2. \u9023\u63a5\u5230 Oracle \u6578\u64da\u5eab<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u4f7f\u7528\u8005\u53ef\u4ee5\u901a\u904e SQL*Plus \u6216\u5176\u4ed6\u5de5\u5177\uff08\u5982 SQL Developer\uff09\u9023\u63a5\u5230\u6578\u64da\u5eab\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528 SQL*Plus \u9023\u63a5\u7684\u57fa\u672c\u6b65\u9a5f\uff1a<\/p>\n<pre><code>sqlplus username\/password@\/\/hostname:port\/service_name<\/code><\/pre>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre><code>sqlplus sys\/password@\/\/localhost:1521\/XE as sysdba<\/code><\/pre>\n<h2 id=\"3-%e5%89%b5%e5%bb%ba%e7%94%a8%e6%88%b6%e5%92%8c%e8%b3%a6%e4%ba%88%e6%ac%8a%e9%99%90-PYeCKCzpKH\">3. \u5275\u5efa\u7528\u6236\u548c\u8ce6\u4e88\u6b0a\u9650<\/h2>\n<p>\u5728 Oracle \u4e2d\uff0c\u7ba1\u7406\u7528\u6236\u548c\u6b0a\u9650\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u4ee5\u4e0b\u662f\u5275\u5efa\u7528\u6236\u548c\u8ce6\u4e88\u6b0a\u9650\u7684\u57fa\u672c SQL \u8a9e\u53e5\uff1a<\/p>\n<pre><code>CREATE USER new_user IDENTIFIED BY user_password;<\/code><\/pre>\n<pre><code>GRANT CONNECT, RESOURCE TO new_user;<\/code><\/pre>\n<p>\u9019\u6a23\uff0c\u65b0\u7684\u7528\u6236\u5c31\u53ef\u4ee5\u9023\u63a5\u5230\u6578\u64da\u5eab\u4e26\u4f7f\u7528\u57fa\u672c\u7684\u8cc7\u6e90\u3002<\/p>\n<h2 id=\"4-%e5%89%b5%e5%bb%ba%e5%92%8c%e7%ae%a1%e7%90%86%e8%a1%a8-PYeCKCzpKH\">4. \u5275\u5efa\u548c\u7ba1\u7406\u8868<\/h2>\n<p>\u5728 Oracle \u4e2d\uff0c\u8868\u662f\u6578\u64da\u5b58\u5132\u7684\u57fa\u672c\u55ae\u4f4d\u3002\u5275\u5efa\u8868\u7684\u57fa\u672c\u8a9e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>CREATE TABLE employees (\n    employee_id NUMBER PRIMARY KEY,\n    first_name VARCHAR2(50),\n    last_name VARCHAR2(50),\n    hire_date DATE\n);<\/code><\/pre>\n<p>\u7ba1\u7406\u8868\u7684\u64cd\u4f5c\u5305\u62ec\u63d2\u5165\u3001\u66f4\u65b0\u548c\u522a\u9664\u6578\u64da\uff1a<\/p>\n<ul>\n<li>\u63d2\u5165\u6578\u64da\uff1a<\/li>\n<pre><code>INSERT INTO employees (employee_id, first_name, last_name, hire_date) \nVALUES (1, 'John', 'Doe', TO_DATE('2023-01-01', 'YYYY-MM-DD'));<\/code><\/pre>\n<li>\u66f4\u65b0\u6578\u64da\uff1a<\/li>\n<pre><code>UPDATE employees SET last_name = 'Smith' WHERE employee_id = 1;<\/code><\/pre>\n<li>\u522a\u9664\u6578\u64da\uff1a<\/li>\n<pre><code>DELETE FROM employees WHERE employee_id = 1;<\/code><\/pre>\n<\/ul>\n<h2 id=\"5-%e6%9f%a5%e8%a9%a2%e6%95%b8%e6%93%9a-PYeCKCzpKH\">5. \u67e5\u8a62\u6578\u64da<\/h2>\n<p>\u67e5\u8a62\u6578\u64da\u662f\u4f7f\u7528 Oracle \u7684\u4e00\u500b\u91cd\u8981\u64cd\u4f5c\u3002\u57fa\u672c\u7684\u67e5\u8a62\u8a9e\u53e5\u5982\u4e0b\uff1a<\/p>\n<pre><code>SELECT * FROM employees;<\/code><\/pre>\n<p>\u53ef\u4ee5\u4f7f\u7528 WHERE \u5b50\u53e5\u4f86\u904e\u6ffe\u7d50\u679c\uff1a<\/p>\n<pre><code>SELECT * FROM employees WHERE last_name = 'Smith';<\/code><\/pre>\n<h2 id=\"6-%e6%95%b8%e6%93%9a%e5%82%99%e4%bb%bd%e8%88%87%e6%81%a2%e5%be%a9-PYeCKCzpKH\">6. \u6578\u64da\u5099\u4efd\u8207\u6062\u5fa9<\/h2>\n<p>\u6578\u64da\u5099\u4efd\u662f\u78ba\u4fdd\u6578\u64da\u5b89\u5168\u7684\u91cd\u8981\u63aa\u65bd\u3002Oracle \u63d0\u4f9b\u4e86\u591a\u7a2e\u5099\u4efd\u548c\u6062\u5fa9\u7684\u5de5\u5177\u548c\u65b9\u6cd5\uff0c\u5305\u62ec RMAN\uff08Recovery Manager\uff09\u3002\u4f7f\u7528 RMAN \u9032\u884c\u5099\u4efd\u7684\u57fa\u672c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre><code>RMAN&gt; BACKUP DATABASE;<\/code><\/pre>\n<p>\u6062\u5fa9\u6578\u64da\u7684\u547d\u4ee4\u5247\u70ba\uff1a<\/p>\n<pre><code>RMAN&gt; RESTORE DATABASE;<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-PYeCKCzpKH\">\u7e3d\u7d50<\/h2>\n<p>\u672c\u6587\u4ecb\u7d39\u4e86\u521d\u5b78\u8005\u5728\u5b78\u7fd2 Oracle \u6578\u64da\u5eab\u6642\u5e38\u898b\u7684\u64cd\u4f5c\uff0c\u5305\u62ec\u5b89\u88dd\u3001\u9023\u63a5\u3001\u7528\u6236\u7ba1\u7406\u3001\u8868\u7684\u5275\u5efa\u8207\u7ba1\u7406\u3001\u6578\u64da\u67e5\u8a62\u4ee5\u53ca\u5099\u4efd\u8207\u6062\u5fa9\u7b49\u3002\u9019\u4e9b\u57fa\u672c\u64cd\u4f5c\u662f\u638c\u63e1 Oracle \u6578\u64da\u5eab\u7684\u57fa\u790e\uff0c\u5c0d\u65bc\u9032\u4e00\u6b65\u6df1\u5165\u5b78\u7fd2\u548c\u5be6\u8e10\u81f3\u95dc\u91cd\u8981\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5c0d\u65bc\u66f4\u9ad8\u6548\u7684\u6578\u64da\u7ba1\u7406\u548c\u904b\u884c\u74b0\u5883\u611f\u8208\u8da3\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684 Oracle \u6578\u64da\u5eab\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u521d\u5b78 Oracle \u5b78\u7fd2\u7b46\u8a18\uff0c\u7e3d\u7d50\u5e38\u898b\u64cd\u4f5c\uff0c\u5e6b\u52a9\u65b0\u624b\u5feb\u901f\u638c\u63e1 Oracle \u6578\u64da\u5eab\u7684\u57fa\u672c\u4f7f\u7528\u6280\u5de7\u8207\u5be6\u7528\u65b9\u6cd5\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-152935","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152935","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=152935"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152935\/revisions"}],"predecessor-version":[{"id":152936,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152935\/revisions\/152936"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=152935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=152935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=152935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}