{"id":85003,"date":"2024-10-17T12:34:16","date_gmt":"2024-10-17T04:34:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/85003\/"},"modified":"2024-10-17T12:34:17","modified_gmt":"2024-10-17T04:34:17","slug":"ora-12716-%e7%95%b6%e5%ad%98%e5%9c%a8-clob-%e6%95%b8%e6%93%9a%e6%99%82%e7%84%a1%e6%b3%95-alter-database-character-set%e3%80%82oracle-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9-%e9%81%a0","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/85003\/","title":{"rendered":"ORA-12716: \u7576\u5b58\u5728 CLOB \u6578\u64da\u6642\u7121\u6cd5 ALTER DATABASE CHARACTER SET\u3002ORACLE \u5831\u932f \u6545\u969c\u4fee\u5fa9 \u9060\u7a0b\u8655\u7406"},"content":{"rendered":"<h1 id=\"ora-12716-%e7%95%b6%e5%ad%98%e5%9c%a8-clob-%e6%95%b8%e6%93%9a%e6%99%82%e7%84%a1%e6%b3%95-alter-database-character-set-atvrKwTsqN\">ORA-12716: \u7576\u5b58\u5728 CLOB \u6578\u64da\u6642\u7121\u6cd5 ALTER DATABASE CHARACTER SET<\/h1>\n<p>\u5728\u4f7f\u7528 Oracle \u6578\u64da\u5eab\u6642\uff0c\u958b\u767c\u8005\u548c\u6578\u64da\u5eab\u7ba1\u7406\u54e1\u53ef\u80fd\u6703\u9047\u5230\u5404\u7a2e\u932f\u8aa4\u4ee3\u78bc\uff0c\u5176\u4e2d\u4e4b\u4e00\u4fbf\u662f <code>ORA-12716<\/code>\u3002\u9019\u500b\u932f\u8aa4\u901a\u5e38\u51fa\u73fe\u5728\u5617\u8a66\u66f4\u6539\u6578\u64da\u5eab\u5b57\u7b26\u96c6\u6642\uff0c\u5c24\u5176\u662f\u5728\u6578\u64da\u5eab\u4e2d\u5b58\u5728 CLOB\uff08Character Large Object\uff09\u6578\u64da\u7684\u60c5\u6cc1\u4e0b\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e\u9019\u500b\u932f\u8aa4\u7684\u539f\u56e0\u3001\u5f71\u97ff\u4ee5\u53ca\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n<h2 id=\"ora-12716-%e9%8c%af%e8%aa%a4%e7%9a%84%e5%8e%9f%e5%9b%a0-atvrKwTsqN\">ORA-12716 \u932f\u8aa4\u7684\u539f\u56e0<\/h2>\n<p>\u7576\u6578\u64da\u5eab\u4e2d\u5b58\u5728 CLOB \u6578\u64da\u6642\uff0cOracle \u4e0d\u5141\u8a31\u76f4\u63a5\u66f4\u6539\u6578\u64da\u5eab\u7684\u5b57\u7b26\u96c6\u3002\u9019\u662f\u56e0\u70ba CLOB \u6578\u64da\u985e\u578b\u53ef\u4ee5\u5b58\u5132\u5927\u91cf\u7684\u5b57\u7b26\u6578\u64da\uff0c\u4e26\u4e14\u5176\u5b57\u7b26\u96c6\u7684\u8b8a\u66f4\u53ef\u80fd\u6703\u5c0e\u81f4\u6578\u64da\u640d\u58de\u6216\u4e1f\u5931\u3002\u5177\u9ad4\u4f86\u8aaa\uff0c\u7576\u4f60\u5617\u8a66\u57f7\u884c\u4ee5\u4e0b SQL \u8a9e\u53e5\u6642\uff0c\u4fbf\u6703\u9047\u5230\u6b64\u932f\u8aa4\uff1a<\/p>\n<pre><code>ALTER DATABASE CHARACTER SET '\u65b0\u5b57\u7b26\u96c6';\n<\/code><\/pre>\n<p>\u5728\u9019\u7a2e\u60c5\u6cc1\u4e0b\uff0cOracle \u6703\u6aa2\u67e5\u6578\u64da\u5eab\u4e2d\u7684 CLOB \u6578\u64da\uff0c\u4e26\u767c\u73fe\u5176\u5b57\u7b26\u96c6\u8207\u65b0\u5b57\u7b26\u96c6\u4e0d\u517c\u5bb9\uff0c\u56e0\u6b64\u5831\u544a\u932f\u8aa4 <code>ORA-12716<\/code>\u3002<\/p>\n<h2 id=\"%e5%bd%b1%e9%9f%bf-atvrKwTsqN\">\u5f71\u97ff<\/h2>\n<p>\u9019\u500b\u932f\u8aa4\u7684\u5f71\u97ff\u4e3b\u8981\u9ad4\u73fe\u5728\u6578\u64da\u5eab\u7684\u7dad\u8b77\u548c\u5347\u7d1a\u904e\u7a0b\u4e2d\u3002\u82e5\u7121\u6cd5\u66f4\u6539\u5b57\u7b26\u96c6\uff0c\u5247\u53ef\u80fd\u6703\u5f71\u97ff\u5230\u61c9\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u6578\u64da\u7684\u5b8c\u6574\u6027\u3002\u6b64\u5916\uff0c\u9019\u4e5f\u53ef\u80fd\u5c0e\u81f4\u958b\u767c\u8005\u5728\u9032\u884c\u6578\u64da\u9077\u79fb\u6216\u6574\u5408\u6642\u9047\u5230\u56f0\u96e3\u3002<\/p>\n<h2 id=\"%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9%e6%ad%a5%e9%a9%9f-atvrKwTsqN\">\u6545\u969c\u4fee\u5fa9\u6b65\u9a5f<\/h2>\n<p>\u8981\u89e3\u6c7a <code>ORA-12716<\/code> \u932f\u8aa4\uff0c\u901a\u5e38\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e7%a2%ba%e8%aa%8d-clob-%e6%95%b8%e6%93%9a%e7%9a%84%e5%ad%98%e5%9c%a8-atvrKwTsqN\">1. \u78ba\u8a8d CLOB \u6578\u64da\u7684\u5b58\u5728<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u78ba\u8a8d\u6578\u64da\u5eab\u4e2d\u662f\u5426\u5b58\u5728 CLOB \u6578\u64da\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u67e5\u8a62\u4f86\u6aa2\u67e5\uff1a<\/p>\n<pre><code>SELECT COUNT(*) FROM user_tab_columns WHERE data_type = 'CLOB';\n<\/code><\/pre>\n<h3 id=\"2-%e5%b0%87-clob-%e6%95%b8%e6%93%9a%e8%bd%89%e6%8f%9b%e7%82%ba%e5%85%b6%e4%bb%96%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b-atvrKwTsqN\">2. \u5c07 CLOB \u6578\u64da\u8f49\u63db\u70ba\u5176\u4ed6\u6578\u64da\u985e\u578b<\/h3>\n<p>\u5982\u679c\u78ba\u5be6\u5b58\u5728 CLOB \u6578\u64da\uff0c\u60a8\u53ef\u4ee5\u8003\u616e\u5c07\u5176\u8f49\u63db\u70ba\u5176\u4ed6\u6578\u64da\u985e\u578b\uff0c\u4f8b\u5982 VARCHAR2\u3002\u9019\u53ef\u4ee5\u901a\u904e\u5275\u5efa\u4e00\u500b\u65b0\u7684\u8868\u4f86\u5be6\u73fe\uff1a<\/p>\n<pre><code>CREATE TABLE new_table AS SELECT CAST(clob_column AS VARCHAR2(4000)) AS clob_column FROM old_table;\n<\/code><\/pre>\n<h3 id=\"3-%e5%88%aa%e9%99%a4%e5%8e%9f%e6%9c%89%e7%9a%84-clob-%e6%95%b8%e6%93%9a-atvrKwTsqN\">3. \u522a\u9664\u539f\u6709\u7684 CLOB \u6578\u64da<\/h3>\n<p>\u5728\u78ba\u8a8d\u6578\u64da\u5df2\u6210\u529f\u8f49\u63db\u5f8c\uff0c\u60a8\u53ef\u4ee5\u522a\u9664\u539f\u6709\u7684 CLOB \u6578\u64da\uff1a<\/p>\n<pre><code>DROP TABLE old_table;\n<\/code><\/pre>\n<h3 id=\"4-%e6%9b%b4%e6%94%b9%e5%ad%97%e7%ac%a6%e9%9b%86-atvrKwTsqN\">4. \u66f4\u6539\u5b57\u7b26\u96c6<\/h3>\n<p>\u73fe\u5728\uff0c\u60a8\u53ef\u4ee5\u5b89\u5168\u5730\u66f4\u6539\u6578\u64da\u5eab\u7684\u5b57\u7b26\u96c6\uff1a<\/p>\n<pre><code>ALTER DATABASE CHARACTER SET '\u65b0\u5b57\u7b26\u96c6';\n<\/code><\/pre>\n<h3 id=\"5-%e6%81%a2%e5%be%a9%e6%95%b8%e6%93%9a-atvrKwTsqN\">5. \u6062\u5fa9\u6578\u64da<\/h3>\n<p>\u6700\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5c07\u8f49\u63db\u5f8c\u7684\u6578\u64da\u6062\u5fa9\u5230\u6578\u64da\u5eab\u4e2d\uff1a<\/p>\n<pre><code>INSERT INTO old_table SELECT * FROM new_table;\n<\/code><\/pre>\n<h2 id=\"%e7%b5%90%e8%ab%96-atvrKwTsqN\">\u7d50\u8ad6<\/h2>\n<p>\u5728 Oracle \u6578\u64da\u5eab\u4e2d\u9047\u5230 <code>ORA-12716<\/code> \u932f\u8aa4\u6642\uff0c\u4e86\u89e3\u5176\u539f\u56e0\u548c\u89e3\u6c7a\u65b9\u6848\u81f3\u95dc\u91cd\u8981\u3002\u901a\u904e\u9075\u5faa\u4e0a\u8ff0\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u6c7a\u6b64\u554f\u984c\uff0c\u4e26\u78ba\u4fdd\u6578\u64da\u5eab\u7684\u6b63\u5e38\u904b\u884c\u3002\u5c0d\u65bc\u9700\u8981\u9ad8\u6548\u6578\u64da\u8655\u7406\u7684\u4f01\u696d\u4f86\u8aaa\uff0c\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4e5f\u662f\u4e00\u500b\u91cd\u8981\u7684\u8003\u91cf\uff0c\u9019\u6a23\u53ef\u4ee5\u78ba\u4fdd\u6578\u64da\u7684\u5b89\u5168\u6027\u548c\u53ef\u7528\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u6c7a ORA-12716 \u932f\u8aa4\uff1a\u7576\u5b58\u5728 CLOB \u6578\u64da\u6642\u7121\u6cd5\u66f4\u6539\u6578\u64da\u5eab\u5b57\u7b26\u96c6\u7684\u6545\u969c\u4fee\u5fa9\u8207\u9060\u7a0b\u8655\u7406\u6307\u5357\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-85003","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/85003","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=85003"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/85003\/revisions"}],"predecessor-version":[{"id":85004,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/85003\/revisions\/85004"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=85003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=85003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=85003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}