{"id":38742,"date":"2025-05-21T10:34:39","date_gmt":"2025-05-21T02:34:39","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/38742.html"},"modified":"2025-05-21T10:34:39","modified_gmt":"2025-05-21T02:34:39","slug":"oracle%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/38742.html","title":{"rendered":"Oracle\u57fa\u7840\u77e5\u8bc6"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"1.%E5%88%AB%E5%90%8D%E7%9A%84%E4%BD%BF%E7%94%A8-toc\" style=\"margin-left:40px\">1.\u522b\u540d\u7684\u4f7f\u7528<\/p>\n<p id=\"2.AND%E7%9A%84%E4%BC%98%E5%85%88%E7%BA%A7%E9%AB%98%E4%BA%8EOR-toc\" style=\"margin-left:40px\">2.AND\u7684\u4f18\u5148\u7ea7\u9ad8\u4e8eOR<\/p>\n<p id=\"3.where%E5%90%8E%E9%9D%A2%E5%8F%AF%E4%BB%A5%E6%8E%A5%E5%88%AB%E5%90%8D%EF%BC%8Corder%20by%E5%90%8E%E9%9D%A2%E4%B8%8D%E5%8F%AF%E4%BB%A5-toc\" style=\"margin-left:40px\">3.where\u540e\u9762\u53ef\u4ee5\u63a5\u522b\u540d&#xff0c;order by\u540e\u9762\u4e0d\u53ef\u4ee5<\/p>\n<p id=\"4.Oracle%E4%B8%ADSQL%E7%9A%84%E6%89%A7%E8%A1%8C%E9%A1%BA%E5%BA%8F(%E9%87%8D%E7%82%B9)-toc\" style=\"margin-left:40px\">4.Oracle\u4e2dSQL\u7684\u6267\u884c\u987a\u5e8f(\u91cd\u70b9)<\/p>\n<p id=\"5.dual%E4%B8%87%E7%94%A8%E8%A1%A8-toc\" style=\"margin-left:40px\">5.dual\u4e07\u7528\u8868<\/p>\n<p id=\"6.%E6%98%AF%E5%90%A6%E5%8C%BA%E5%88%86%E5%A4%A7%E5%B0%8F%E5%86%99-toc\" style=\"margin-left:40px\">6.\u662f\u5426\u533a\u5206\u5927\u5c0f\u5199<\/p>\n<p id=\"7.Oracle%E5%B8%B8%E7%94%A8%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B-toc\" style=\"margin-left:40px\">7.Oracle\u5e38\u7528\u6570\u636e\u7c7b\u578b<\/p>\n<p id=\"8.Oracle%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:40px\">8.Oracle\u5e38\u7528\u51fd\u6570<\/p>\n<p id=\"(1)length%E5%AD%97%E7%AC%A6%E3%80%81lengthb%E5%AD%97%E8%8A%82%E5%92%8Ccast%E5%BC%BA%E5%88%B6%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2-toc\" style=\"margin-left:80px\">(1)length\u5b57\u7b26\u3001lengthb\u5b57\u8282\u548ccast\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362<\/p>\n<p id=\"(2)%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2-toc\" style=\"margin-left:80px\">(2)\u6570\u636e\u7c7b\u578b\u8f6c\u6362<\/p>\n<p id=\"to_date()%EF%BC%9A%E5%B0%86%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%BD%AC%E6%8D%A2%E4%B8%BA%E6%97%A5%E6%9C%9F%E7%B1%BB%E5%9E%8B%C2%A0-toc\" style=\"margin-left:120px\">to_date()&#xff1a;\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u671f\u7c7b\u578b\u00a0<\/p>\n<p id=\"to_char()%EF%BC%9A%E5%B0%86%E6%97%A5%E6%9C%9F%E3%80%81%E6%97%B6%E9%97%B4%E6%88%B3%E6%88%96%E6%95%B0%E5%AD%97%E8%BD%AC%E6%8D%A2%E4%B8%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%A0%BC%E5%BC%8F-toc\" style=\"margin-left:120px\">to_char()&#xff1a;\u5c06\u65e5\u671f\u3001\u65f6\u95f4\u6233\u6216\u6570\u5b57\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u683c\u5f0f<\/p>\n<p id=\"%C2%A0to_number()%EF%BC%9A%E5%B0%86%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%BD%AC%E4%B8%BA%E6%95%B0%E5%AD%97%E7%B1%BB%E5%9E%8B-toc\" style=\"margin-left:120px\">to_number()&#xff1a;\u5c06\u5b57\u7b26\u4e32\u8f6c\u4e3a\u6570\u5b57\u7c7b\u578b<\/p>\n<p id=\"9.NOT%20BETWEEN%C2%A0%20AND%20%E5%8F%8D%E5%90%91%E5%8C%BA%E9%97%B4-toc\" style=\"margin-left:40px\">9.NOT BETWEEN\u00a0 AND \u53cd\u5411\u533a\u95f4<\/p>\n<p id=\"10.NOT%20IN-toc\" style=\"margin-left:40px\">10.NOT IN<\/p>\n<p id=\"11.LIKE%E6%A8%A1%E7%B3%8A%E6%9F%A5%E8%AF%A2-toc\" style=\"margin-left:40px\">11.LIKE\u6a21\u7cca\u67e5\u8be2<\/p>\n<p id=\"12.%E7%A9%BA%E5%80%BCNULL-toc\" style=\"margin-left:40px\">12.\u7a7a\u503cNULL<\/p>\n<p id=\"(1)%E7%A9%BA%E5%80%BC%E7%9A%84%E8%BF%87%E6%BB%A4-toc\" style=\"margin-left:80px\">(1)\u7a7a\u503c\u7684\u8fc7\u6ee4<\/p>\n<p id=\"(2)%E7%A9%BA%E5%80%BC%E7%9A%84%E6%8E%92%E5%BA%8F-toc\" style=\"margin-left:80px\">(2)\u7a7a\u503c\u7684\u6392\u5e8f<\/p>\n<p id=\"(3)%E7%A9%BA%E5%80%BC%E8%BF%90%E7%AE%97-toc\" style=\"margin-left:80px\">(3)\u7a7a\u503c\u8fd0\u7b97<\/p>\n<p id=\"(4)%E7%A9%BA%E5%80%BC%E8%BD%AC%E6%8D%A2NVL%E4%B8%8ENVL2-toc\" style=\"margin-left:80px\">(4)\u7a7a\u503c\u8f6c\u6362NVL\u4e0eNVL2<\/p>\n<hr id=\"hr-toc\" \/>\n<h3>1.\u522b\u540d\u7684\u4f7f\u7528<\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">\u00a0<span style=\"color:#fe2c24\">\u522b\u540d&#8211;\u6570\u5b57\u3001\u5b57\u6bcd\u3001\u4e0b\u5212\u7ebf\u7ec4\u6210&#xff0c;\u4e0d\u80fd\u6570\u5b57\u548c\u7b26\u53f7\u6253\u5934<\/span>\u00a0<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">\u5fc5\u987b\u4ee5\u5b57\u6bcd\u5f00\u5934&#xff1b;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">\u957f\u5ea6\u4e0d\u80fd\u8d85\u8fc7 30\u00a0\u4e2a\u5b57\u7b26&#xff1b;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">\u53ea\u80fd\u5305\u542b\u5b57\u6bcd&#xff08;A-Z\u3001a-z&#xff09;\u3001\u6570\u5b57&#xff08;0-9&#xff09;\u3001\u4e0b\u5212\u7ebf&#xff08;_&#xff09;\u548c\u7f8e\u5143\u7b26\u53f7&#xff08;$&#xff09;&#xff1b;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">\u4e0d\u80fd\u4f7f\u7528 Oracle \u7684\u4fdd\u7559\u5b57&#xff08;\u6bd4\u5982&#xff1a;SELECT\u3001FROM\u3001WHERE\u2026\u2026&#xff09;&#xff1b;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">\u4e0d\u80fd\u548c\u540c\u4e00\u4e2a\u7528\u6237\u4e0b\u7684\u5176\u4ed6\u5bf9\u8c61\u91cd\u540d&#xff1b;<\/span><\/p>\n<p>\u4e2d\u6587\u522b\u540d&#xff0c;as\u53ef\u4ee5\u7701\u7565<\/p>\n<p>\u8868\u7684\u522b\u540d\u4e0d\u80fd\u4f7f\u7528as<span style=\"color:null\">\u3002<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">\u5982\u679c\u60f3\u4f7f\u7528\u4e00\u4e9b\u7279\u6b8a\u5b57\u7b26\u6216\u4e0d\u7b26\u5408\u4e0a\u8ff0\u89c4\u5219\u7684\u540d\u79f0\u4f5c\u4e3a\u522b\u540d&#xff0c;\u53ef\u4ee5\u5c06\u522b\u540d\u7528\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\u3002<\/span><\/p>\n<p>select ename \u5458\u5de5\u59d3\u540d, sal as &#034;\u5458\u5de5\u85aa\u8d44&#034;, deptno &#034;\u90e8\u95e8\u7f16\u53f7&#034;<br \/>\n  from emp<br \/>\n where job &#061; &#039;SALESMAN&#039;;<\/p>\n<h3 id=\"2.AND%E7%9A%84%E4%BC%98%E5%85%88%E7%BA%A7%E9%AB%98%E4%BA%8EOR\">2.AND\u7684\u4f18\u5148\u7ea7\u9ad8\u4e8eOR<\/h3>\n<p>\u4f7f\u7528\u62ec\u53f7\u660e\u786e\u4f18\u5148\u7ea7&#xff1a;<\/p>\n<p>SELECT * FROM employees<br \/>\nWHERE (dept_id &#061; 10 OR dept_id &#061; 20) AND salary &gt; 5000; <\/p>\n<h3 id=\"3.where%E5%90%8E%E9%9D%A2%E5%8F%AF%E4%BB%A5%E6%8E%A5%E5%88%AB%E5%90%8D%EF%BC%8Corder%20by%E5%90%8E%E9%9D%A2%E4%B8%8D%E5%8F%AF%E4%BB%A5\">3.where\u540e\u9762\u53ef\u4ee5\u63a5\u522b\u540d&#xff0c;order by\u540e\u9762\u4e0d\u53ef\u4ee5<\/h3>\n<p>\u5177\u4f53\u539f\u56e0\u662f\u6839\u636eOracle\u4e2dSQL\u7684\u6267\u884c\u987a\u5e8f\u6765\u7684&#xff0c;\u8be6\u89c1\u4e0b\u9762\u00a0<\/p>\n<h3 id=\"4.Oracle%E4%B8%ADSQL%E7%9A%84%E6%89%A7%E8%A1%8C%E9%A1%BA%E5%BA%8F(%E9%87%8D%E7%82%B9)\">4.<span style=\"color:#fe2c24\">Oracle\u4e2dSQL\u7684\u6267\u884c\u987a\u5e8f(\u91cd\u70b9)<\/span><\/h3>\n<\/p>\n<li>FROM&#xff1a;\u9996\u5148\u786e\u5b9a\u6570\u636e\u6765\u6e90&#xff0c;\u5305\u62ec\u8868\u3001\u89c6\u56fe\u7b49&#xff0c;\u5e76\u5904\u7406\u4efb\u4f55\u8fde\u63a5(JOIN)\u64cd\u4f5c\u3002<\/li>\n<li>WHERE&#xff1a;\u5e94\u7528\u8fc7\u6ee4\u6761\u4ef6\u6765\u7b5b\u9009\u884c\u3002<\/li>\n<li>GROUP BY&#xff1a;\u5c06\u7ed3\u679c\u96c6\u6309\u6307\u5b9a\u5217\u5206\u7ec4\u3002<\/li>\n<li>HAVING&#xff1a;\u5bf9\u5206\u7ec4\u540e\u7684\u7ed3\u679c\u8fdb\u884c\u6761\u4ef6\u8fc7\u6ee4\u3002<\/li>\n<li>SELECT&#xff1a;\u9009\u62e9\u9700\u8981\u663e\u793a\u7684\u5217\u6216\u8868\u8fbe\u5f0f&#xff0c;\u5e76\u6267\u884c\u4efb\u4f55\u8ba1\u7b97\u6216\u51fd\u6570\u8c03\u7528\u3002<\/li>\n<li>ORDER BY&#xff1a;\u6839\u636e\u6307\u5b9a\u7684\u5217\u5bf9\u6700\u7ec8\u7ed3\u679c\u8fdb\u884c\u6392\u5e8f\u3002<\/li>\n<li>OFFSET-FETCH\/ROWNUM&#xff1a;\u9650\u5236\u8fd4\u56de\u7684\u884c\u6570&#xff08;\u5982\u5206\u9875\u529f\u80fd&#xff09;\u3002\u6ce8\u610f&#xff0c;OFFSET-FETCH\u662f\u8f83\u65b0\u7684\u8bed\u6cd5&#xff0c;\u800cROWNUM\u662fOracle\u7279\u6709\u7684\u7528\u4e8e\u9650\u5236\u7ed3\u679c\u96c6\u5927\u5c0f\u7684\u65b9\u6cd5\u3002<\/li>\n<h3 id=\"5.dual%E4%B8%87%E7%94%A8%E8%A1%A8\">5.dual\u4e07\u7528\u8868<\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ff0000\"><span style=\"background-color:null\">dual\/\u4e07\u80fd\u8868\/\u4f2a\u8868 <\/span><\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ff0000\"><span style=\"background-color:null\">Oracle \u4e2ddual\u8868\u7684\u5b58\u5728\u4e3b\u8981\u662f\u4e3a\u4e86\u6ee1\u8db3\u8bed\u6cd5\u8981\u6c42\u548c\u63d0\u4f9b\u4e00\u4e9b\u4fbf\u5229\u3002<\/span><\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ff0000\"><span style=\"background-color:null\">dual\u8868\u662f Oracle \u4e0e\u6570\u636e\u5b57\u5178\u4e00\u8d77\u81ea\u52a8\u521b\u5efa\u7684\u4e00\u4e2a\u5355\u884c\u5355\u5217\u7684\u865a\u62df\u8868&#xff0c;\u5b83\u53ea\u6709\u4e00\u5217<\/span><\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ff0000\"><span style=\"background-color:null\">\u865a\u62df\u7684&#xff0c;\u4e0d\u5305\u542b\u4efb\u4f55\u6570\u636e<\/span><\/span><\/p>\n<p>select 7&#043;9 from dual;<\/p>\n<p>select sysdate from dual; <\/p>\n<h3 id=\"6.%E6%98%AF%E5%90%A6%E5%8C%BA%E5%88%86%E5%A4%A7%E5%B0%8F%E5%86%99\">6.\u662f\u5426\u533a\u5206\u5927\u5c0f\u5199<\/h3>\n<p>\u5b57\u7b26\u4e32\u91cc\u9762\u8981\u533a\u5206\u5927\u5c0f\u5199<\/p>\n<p>\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684&#xff1a;\u5b57\u6bb5\u540d\u3001\u8868\u540d<\/p>\n<p>select * from emp where ename&#061;&#039;SCOTT&#039;; <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"58\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521023437-682d3bbdd9802.png\" width=\"653\" \/><\/p>\n<p>select * from emp where ename&#061;&#039;scott&#039;; <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"47\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521023437-682d3bbdea4f6.png\" width=\"638\" \/><\/p>\n<h3 id=\"7.Oracle%E5%B8%B8%E7%94%A8%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B\">7.Oracle\u5e38\u7528\u6570\u636e\u7c7b\u578b<\/h3>\n<table>\n<tr>\u6570\u636e\u7c7b\u578b\u7c7b\u522b\u6570\u636e\u7c7b\u578b\u63cf\u8ff0\u793a\u4f8b\/\u5907\u6ce8<\/tr>\n<tbody>\n<tr>\n<td>\u6570\u503c\u7c7b\u578b<\/td>\n<td><span style=\"color:#fe2c24\">NUMBER(p,s)<\/span><\/td>\n<td>\n<p>\u5b58\u50a8\u56fa\u5b9a\u6216\u6d6e\u52a8\u7684\u6570\u503c&#xff0c;<\/p>\n<p>p\u662f\u7cbe\u5ea6&#xff08;\u603b\u4f4d\u6570&#xff09;&#xff0c;s\u662f\u6807\u5ea6&#xff08;\u5c0f\u6570\u70b9\u540e\u7684\u4f4d\u6570&#xff09;\u3002<\/p>\n<\/td>\n<td>NUMBER(5,2)\u00a0\u8868\u793a\u6700\u591a5\u4f4d\u6570\u5b57&#xff0c;\u5176\u4e2d2\u4f4d\u5728\u5c0f\u6570\u70b9\u4e4b\u540e\u3002<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"6\">\u5b57\u7b26\u4e32\u7c7b\u578b<\/td>\n<td><span style=\"color:#fe2c24\">VARCHAR2(size)<\/span><\/td>\n<td>\u53ef\u53d8\u957f\u5ea6\u5b57\u7b26\u6570\u636e\u7c7b\u578b&#xff0c;size\u6307\u6700\u5927\u5b57\u8282\u957f\u5ea6&#xff0c;\u8303\u56f41\u52304000\u5b57\u8282\u3002<\/td>\n<td>\n<p>VARCHAR2(100)\u00a0\u6700\u5927\u5b58\u50a8100\u4e2a\u5b57\u7b26\u3002<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>NVARCHAR2(size)<\/td>\n<td>\u7c7b\u4f3c\u4e8eVARCHAR2&#xff0c;\u4f46\u4f7f\u7528\u56fd\u5bb6\u5b57\u7b26\u96c6&#xff0c;\u9002\u7528\u4e8e\u591a\u8bed\u8a00\u73af\u5883\u3002<\/td>\n<td>NVARCHAR2(100)\u00a0\u4f7f\u7528\u56fd\u5bb6\u5b57\u7b26\u96c6\u5b58\u50a8\u6700\u591a100\u4e2a\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">CHAR(size)<\/span><\/td>\n<td>\u56fa\u5b9a\u957f\u5ea6\u5b57\u7b26\u6570\u636e\u7c7b\u578b&#xff0c;\u5982\u679c\u63d2\u5165\u7684\u5b57\u7b26\u4e32\u77ed\u4e8e\u5b9a\u4e49\u957f\u5ea6&#xff0c;\u5219\u7528\u7a7a\u683c\u586b\u5145\u81f3\u5b9a\u4e49\u957f\u5ea6\u3002<\/td>\n<td>CHAR(100)\u00a0\u603b\u662f\u5360\u7528100\u4e2a\u5b57\u7b26\u7684\u7a7a\u95f4\u3002<\/td>\n<\/tr>\n<tr>\n<td>NCHAR(size)<\/td>\n<td>\u7c7b\u4f3c\u4e8eCHAR&#xff0c;\u4f46\u4f7f\u7528\u56fd\u5bb6\u5b57\u7b26\u96c6\u3002<\/td>\n<td>NCHAR(100)\u00a0\u4f7f\u7528\u56fd\u5bb6\u5b57\u7b26\u96c6\u5e76\u603b\u662f\u5360\u7528100\u4e2a\u5b57\u7b26\u7684\u7a7a\u95f4\u3002<\/td>\n<\/tr>\n<tr>\n<td>CLOB<\/td>\n<td>\u7528\u4e8e\u5b58\u50a8\u5927\u578b\u5b57\u7b26\u6570\u636e&#xff0c;\u6700\u5927\u53ef\u8fbe128TB\u3002<\/td>\n<td>\u9002\u5408\u5b58\u50a8\u5927\u91cf\u7684\u6587\u672c\u6570\u636e\u3002<\/td>\n<\/tr>\n<tr>\n<td>NCLOB<\/td>\n<td>\u7528\u4e8e\u5b58\u50a8\u4f7f\u7528\u56fd\u5bb6\u5b57\u7b26\u96c6\u7f16\u7801\u7684\u5927\u578b\u5b57\u7b26\u6570\u636e\u3002<\/td>\n<td>\u4e0eCLOB\u7c7b\u4f3c&#xff0c;\u4f46\u652f\u6301\u56fd\u5bb6\u5b57\u7b26\u96c6\u3002<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"2\">\u65e5\u671f\/\u65f6\u95f4\u7c7b\u578b<\/td>\n<td><span style=\"color:#fe2c24\">DATE<\/span><\/td>\n<td>\u5b58\u50a8\u65e5\u671f\u548c\u65f6\u95f4\u4fe1\u606f&#xff0c;\u7cbe\u786e\u5230\u79d2\u3002\u683c\u5f0f\u4e3a&#xff1a;\u4e16\u7eaa\u3001\u5e74\u3001\u6708\u3001\u65e5\u3001\u65f6\u3001\u5206\u3001\u79d2\u3002<\/td>\n<td>\u5e38\u7528\u4e8e\u9700\u8981\u540c\u65f6\u8bb0\u5f55\u65e5\u671f\u548c\u65f6\u95f4\u7684\u60c5\u51b5\u3002<\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#fe2c24\">TIMESTAMP<\/span><\/td>\n<td>\u7c7b\u4f3cDATE&#xff0c;\u4f46\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7684\u65f6\u95f4\u7cbe\u5ea6&#xff08;\u7eb3\u79d2\u7ea7&#xff09;&#xff0c;\u5e76\u53ef\u9009\u5305\u542b\u65f6\u533a\u4fe1\u606f\u3002<\/td>\n<td>TIMESTAMP WITH TIME ZONE\u00a0\u6216\u00a0TIMESTAMP WITH LOCAL TIME ZONE\u3002<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"2\">\u5927\u5bf9\u8c61\u7c7b\u578b&#xff08;LOB&#xff09;<\/td>\n<td>BLOB<\/td>\n<td>\u7528\u4e8e\u5b58\u50a8\u4e8c\u8fdb\u5236\u5927\u5bf9\u8c61&#xff0c;\u5982\u56fe\u50cf\u3001\u89c6\u9891\u7b49&#xff0c;\u6700\u5927\u53ef\u8fbe128TB\u3002<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>BFILE<\/td>\n<td>\u7528\u4e8e\u5b58\u50a8\u6307\u5411\u5b58\u50a8\u5728\u6570\u636e\u5e93\u5916\u90e8\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u5927\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u6307\u9488\u3002<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"3\">\u539f\u59cb\u548cROWID\u7c7b\u578b<\/td>\n<td>RAW(size)<\/td>\n<td>\u7528\u4e8e\u5b58\u50a8\u4e8c\u8fdb\u5236\u6570\u636e\u6216\u5b57\u8282\u5b57\u7b26\u4e32&#xff0c;\u5fc5\u987b\u6307\u5b9a\u6700\u5927\u957f\u5ea6&#xff0c;\u8303\u56f4\u4ece1\u52302000\u5b57\u8282\u3002<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>LONG RAW<\/td>\n<td>\u7c7b\u4f3c\u4e8eRAW&#xff0c;\u4f46\u53ef\u7528\u4e8e\u5b58\u50a8\u66f4\u5927\u7684\u4e8c\u8fdb\u5236\u6570\u636e&#xff0c;\u6700\u5927\u53ef\u8fbe2GB\u3002&#xff08;\u4e0d\u63a8\u8350\u7528\u4e8e\u65b0\u5e94\u7528&#xff09;<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>ROWID<\/td>\n<td>\u5b58\u50a8\u884c\u7684\u5730\u5740&#xff0c;\u6bcf\u4e2a\u8868\u4e2d\u7684\u6bcf\u4e00\u884c\u90fd\u6709\u4e00\u4e2a\u552f\u4e00\u7684ROWID\u3002<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"2\">\u5176\u4ed6\u7c7b\u578b<\/td>\n<td>BOOLEAN<\/td>\n<td>\u4ec5\u5728PL\/SQL\u4e2d\u53ef\u7528&#xff0c;\u7528\u4e8e\u5b58\u50a8\u903b\u8f91\u5e03\u5c14\u503c&#xff08;TRUE, FALSE, NULL&#xff09;\u3002\u6ce8\u610f&#xff0c;\u5728SQL\u8bed\u53e5\u4e2d\u5e76\u4e0d\u76f4\u63a5\u652f\u6301BOOLEAN\u7c7b\u578b\u3002<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>XMLType<\/td>\n<td>\u7528\u4e8e\u5b58\u50a8XML\u6570\u636e&#xff0c;\u5e76\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u9488\u5bf9XML\u7684\u64cd\u4f5c\u51fd\u6570\u3002<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"background-color:#ffffff\"><span style=\"color:#ff0000\">CHAR()\u548cVARCHAR2()\u533a\u522b&#xff1a;<\/span><\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#008080\"><span style=\"background-color:null\">CHAR<\/span><\/span><span style=\"color:#000080\"><span style=\"background-color:null\">()\u59cb\u7ec8\u5360\u7528\u5b9a\u4e49\u7684\u6700\u5927\u957f\u5ea6\u7684\u5b58\u50a8\u7a7a\u95f4&#xff0c;\u5982\u679c\u5b58\u50a8\u7684\u6570\u636e\u957f\u5ea6\u5c0f\u4e8e\u8fd9\u4e2a\u957f\u5ea6&#xff0c;\u4f1a\u4f7f\u7528\u7a7a\u683c\u586b\u5145\u5269\u4f59\u7684\u7a7a\u95f4<\/span><\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#008080\"><span style=\"background-color:null\">VARCHAR2<\/span><\/span><span style=\"color:#000080\"><span style=\"background-color:null\">()\u53ea\u5360\u7528\u5b9e\u9645\u5b57\u7b26\u6570\u636e\u7684\u5b58\u50a8\u7a7a\u95f4&#xff0c;\u53ef\u53d8\u957f\u5ea6<\/span><\/span><\/p>\n<h3 id=\"8.Oracle%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0\">8.Oracle\u5e38\u7528\u51fd\u6570<\/h3>\n<h4 id=\"(1)length%E5%AD%97%E7%AC%A6%E3%80%81lengthb%E5%AD%97%E8%8A%82%E5%92%8Ccast%E5%BC%BA%E5%88%B6%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2\">(1)length\u5b57\u7b26\u3001lengthb\u5b57\u8282\u548ccast\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">LENGTH(x)&#xff1a;\u8fd4\u56de\u5b57\u7b26\u4e2a\u6570 11\u00a0&#039;WH&#039;\u00a0&#039;\u4f60\u597d&#039;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/span><span style=\"color:#fe2c24\">&#8212; \u6587\u672c\u4fe1\u606f\u7684\u57fa\u672c\u5355\u4f4d<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">LENGTHB(x)&#xff1a;\u8fd4\u56de\u5b57\u8282\u6570 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color:#fe2c24\">&#8212; \u6570\u636e\u5b58\u50a8\u7684\u57fa\u672c\u5355\u4f4d<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">CAST()&#xff1a;\u8f6c\u6362\u6570\u636e\u7c7b\u578b\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/span><span style=\"color:#fe2c24\">&#8212; cast(&#039;123&#039; as number)<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#fe2c24\">&#8212; \u4e00\u4e2a\u82f1\u6587\/\u6570\u5b57\u5360\u75281\u4e2a\u5b57\u8282 &#8212; \u4e00\u4e2a\u4e2d\u6587\u5360\u75282\u4e2a\u5b57\u8282 &#8212; GBK&#xff1a;\u4e00\u4e2a\u6c49\u5b57\u5360\u4e24\u4e2a\u5b57\u8282 &#8212; utf-8&#xff1a;\u4e00\u4e2a\u6c49\u5b57\u5360\u4e09\u4e2a\u5b57\u8282<\/span><\/p>\n<p>select lengthb(&#039;\u4f60\u597d&#039;) from dual; &#8212; 4<\/p>\n<p>select length(&#039;\u4f60\u597d&#039;) from dual; &#8212; 2<\/p>\n<p>select length(cast(123 as char(4))) from dual; &#8212; 4<\/p>\n<p>SELECT LENGTH(11),   &#8212; 2<br \/>\n       LENGTH(&#039;HH&#039;), &#8212; 2<br \/>\n       LENGTHB(&#039;HH&#039;) &#8212; 2<br \/>\nFROM DUAL;<\/p>\n<h4 id=\"(2)%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2\">(2)\u6570\u636e\u7c7b\u578b\u8f6c\u6362<\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"background-color:#ffffff\"><span style=\"color:#ff0000\">&#8211;\u9690\u5f0f\u8f6c\u6362 \u4f1a\u9020\u6210\u7d22\u5f15\u5931\u6548<\/span><\/span><\/p>\n<p>SELECT\u00a0ename e1,ENAME E2&#8211;\u5b57\u6bb5\u4e0d\u533a\u5206\u5927\u5c0f\u5199<br \/>\nFROM\u00a0EMP<br \/>\nWHERE\u00a0DEPTNO&#061;&#039;10&#039;; &#8212; \u9519\u8bef\u5199\u6cd5&#xff0c;\u4f1a\u5bfc\u81f4\u7d22\u5f15\u5931\u6548 <\/p>\n<h5 id=\"to_date()%EF%BC%9A%E5%B0%86%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%BD%AC%E6%8D%A2%E4%B8%BA%E6%97%A5%E6%9C%9F%E7%B1%BB%E5%9E%8B%C2%A0\">to_date()&#xff1a;\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u671f\u7c7b\u578b\u00a0<\/h5>\n<p>TO_DATE(string, format_model) <\/p>\n<p>\u6ce8\u610f&#xff1a;\u524d\u540e\u8981\u4fdd\u6301\u4e00\u81f4\u3002\u00a0<\/p>\n<p><span style=\"background-color:#ffffff\"><span style=\"color:#ff0000\">TO_DATE \u62ec\u53f7\u91cc\u9762 \u5e74\u6708\u65e5\u5fc5\u987b\u5b8c\u6574 \u5426\u5219\u4f1a\u7ed9\u4e00\u4e2a\u9ed8\u8ba4\u503c<\/span><\/span><\/p>\n<p>select to_date(&#039;20250520&#039;, &#039;YYYYMMDD&#039;) as a1,<br \/>\n       to_date(&#039;2025-05-20&#039;, &#039;YYYY-MM-DD&#039;) as a2<br \/>\n  from dual; <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"59\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521023438-682d3bbe0320b.png\" width=\"236\" \/><\/p>\n<p>\u4f8b\u9898&#xff1a;\u67e5\u8be2 \u6240\u6709 1982\u5e74\u4e4b\u524d\u5165\u804c\u7684\u5458\u5de5\u85aa\u8d44&#xff0c;\u8f93\u51fa&#xff1a;\u5458\u5de5\u59d3\u540d \u00a0 \u5458\u5de5\u5165\u804c\u65f6\u95f4 \u00a0\u5458\u5de5\u85aa\u8d44<\/p>\n<p>select EMPNO, hiredate, SAL<br \/>\n  from emp<br \/>\n where hiredate &lt; to_date(&#039;1982-01-01&#039;, &#039;yyyy-MM-DD&#039;)<\/p>\n<hr \/>\n<h5 id=\"to_char()%EF%BC%9A%E5%B0%86%E6%97%A5%E6%9C%9F%E3%80%81%E6%97%B6%E9%97%B4%E6%88%B3%E6%88%96%E6%95%B0%E5%AD%97%E8%BD%AC%E6%8D%A2%E4%B8%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%A0%BC%E5%BC%8F\">to_char()&#xff1a;\u5c06\u65e5\u671f\u3001\u65f6\u95f4\u6233\u6216\u6570\u5b57\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u683c\u5f0f<\/h5>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"background-color:#ffffff\"><span style=\"color:#ff0000\">TO_CHAR \u62ec\u53f7\u91cc\u9762 \u53ef\u4ee5\u53ea\u53d6\u5e74 \u00a0\u53ea\u53d6\u6708 \u00a0\u53ea\u53d6\u65e5<\/span><\/span><\/p>\n<p>select hiredate as a1,<br \/>\n       to_char(hiredate, &#039;YYYYMMDD&#039;) as a2,<br \/>\n       to_char(hiredate, &#039;YYYY-MM-DD&#039;) as a3,<br \/>\n       to_char(hiredate, &#039;MM\/DD\/YYYY&#039;) as a4,<br \/>\n       to_char(hiredate, &#039;YYYY&#039;) as a5,<br \/>\n       to_char(hiredate, &#039;MM\/DD&#039;) as a6<br \/>\n  from emp; <\/p>\n<p>\u4f7f\u7528to_char()\u67e5\u8be21982\u5e74\u4e4b\u524d\u5165\u804c\u7684\u5458\u5de5&#xff1a;\u00a0<\/p>\n<p>select * from emp where to_char(hiredate, &#039;yyyy&#039;) &lt; 1982;<\/p>\n<p>select * from emp where to_number(to_char(hiredate, &#039;yyyy&#039;)) &lt; 1982;<\/p>\n<p>\u5c06\u7cfb\u7edf\u5f53\u524d\u65f6\u95f4 \u4ee5\u5e74\u6708\u65e5\u7684\u5f62\u5f0f\u5c55\u793a&#xff0c;\u5e76\u4e14\u662f\u65e5\u671f\u7c7b\u578b&#xff1a;<\/p>\n<p>&#8212; \u601d\u8def&#xff1a;<br \/>\nSELECT SYSDATE FROM DUAL;&#8211;\u67e5\u770b\u9ed8\u8ba4\u65f6\u95f4\u6837\u5f0f<\/p>\n<p>SELECT TO_CHAR(SYSDATE,&#039;YYYYMMDD&#039;) FROM DUAL;&#8211;\u63d0\u53d6\u5e74\u6708\u65e5\u5b57\u7b26\u4e32\u7c7b\u578b<\/p>\n<p>SELECT TO_DATE(TO_CHAR(SYSDATE,&#039;YYYYMMDD&#039;),&#039;YYYYMMDD&#039;)&#8211;\u8f6c\u5316\u4e3a\u65e5\u671f\u683c\u5f0f<br \/>\nFROM DUAL; <\/p>\n<h5 id=\"%C2%A0to_number()%EF%BC%9A%E5%B0%86%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%BD%AC%E4%B8%BA%E6%95%B0%E5%AD%97%E7%B1%BB%E5%9E%8B\" style=\"background-color:transparent\">to_number()&#xff1a;\u5c06\u5b57\u7b26\u4e32\u8f6c\u4e3a\u6570\u5b57\u7c7b\u578b<\/h5>\n<p>\u5b57\u7b26\u4e32\u9760\u5de6&#xff0c;\u6570\u5b57\u7c7b\u578b\u9760\u53f3<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"131\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521023438-682d3bbe0db97.png\" width=\"513\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">\u603b\u7ed3&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">\u65e5\u671f \u2192 \u5b57\u7b26\u4e32\u7c7b\u578b &#xff1a;TO_CHAR(\u65e5\u671f\u5b57\u6bb5,&#039;\u8f93\u51fa\u683c\u5f0f&#039;) \u00a0&#039;YYYYMMDD&#039;\/&#039;YYYY&#039;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">\u5b57\u7b26\u4e32\u7c7b\u578b \u2192 \u65e5\u671f &#xff1a;TO_DATE(\u5b57\u7b26\u4e32,&#039;\u8f93\u51fa\u683c\u5f0f&#039;) &#039;YYYYMMDD&#039;\/&#039;YYYY-MM-DD&#039;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\">\u5b57\u7b26\u4e32 \u2192 \u6570\u5b57\u7c7b\u578b &#xff1a;TO_NUMBER(\u5b57\u7b26\u4e32) \u00a0\u53ef\u4ee5\u4e0d\u7528 \u505a\u9690\u5f0f\u8f6c\u6362<\/span><\/p>\n<p>&#8211;\u7ec3\u4e60&#xff1a;\u67e5\u8be2\u5165\u804c\u65f6\u95f4\u57281981\u5e74\u7684\u5458\u5de5<br \/>\n&#8211;TO_CAHR<br \/>\nSELECT *<br \/>\nFROM EMP<br \/>\nWHERE TO_CHAR(HIREDATE, &#039;YYYY&#039;) &#061; &#039;1981&#039;;<br \/>\n&#8211;TO_DATE<br \/>\nSELECT *<br \/>\nFROM EMP<br \/>\nWHERE HIREDATE &gt;&#061; TO_DATE(&#039;19810101&#039;, &#039;YYYYMMDD&#039;)<br \/>\n  AND HIREDATE &lt;&#061; TO_DATE(&#039;19811231&#039;, &#039;YYYYMMDD&#039;);<br \/>\n&#8211;NUMBER&#8211;CAST<br \/>\nSELECT *<br \/>\nFROM EMP<br \/>\nWHERE CAST(TO_CHAR(HIREDATE, &#039;YYYY&#039;) AS NUMBER) &#061; 1981; <\/p>\n<h3 id=\"9.NOT%20BETWEEN%C2%A0%20AND%20%E5%8F%8D%E5%90%91%E5%8C%BA%E9%97%B4\">9.<span style=\"color:null\"><span style=\"background-color:#ffffff\">NOT BETWEEN\u00a0 AND \u53cd\u5411\u533a\u95f4<\/span><\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\"><span style=\"background-color:#ffffff\">NOT BETWEEN\u00a0 AND <\/span><\/span><span style=\"background-color:#ffffff\"><span style=\"color:#ff0000\">\u4e0d\u5305\u62ec\u6700\u5927\u503c\u548c\u6700\u5c0f\u503c<\/span><\/span><\/p>\n<p><span style=\"color:null\"><span style=\"background-color:#ffffff\">BETWEEN\u00a0 AND \u662f\u5305\u62ec\u7aef\u70b9\u503c\u7684<\/span><\/span><\/p>\n<p>SELECT *<br \/>\nFROM EMP<br \/>\nWHERE SAL NOT BETWEEN 1000 AND 2000;<br \/>\n&#8211;WHERE SAL&gt;2000 OR SAL&lt;1000; <\/p>\n<h3 id=\"10.NOT%20IN\">10.<span style=\"color:null\"><span style=\"background-color:#ffffff\">NOT IN<\/span><\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\"><span style=\"background-color:#ffffff\">\u793a\u4f8b&#xff1a;\u67e5\u8be2\u6240\u6709\u4e0d\u662f\u7ecf\u7406(MANAGER) \u4e5f\u4e0d\u662f\u6587\u5458(CLERK)\u7684\u4fe1\u606f\u00a0 \u00a0\u00a0&#8211;AND\/OR<\/span><\/span><\/p>\n<p>SELECT *<br \/>\nFROM EMP<br \/>\nWHERE JOB &lt;&gt; &#039;MANAGER&#039;<br \/>\n  AND JOB &lt;&gt; &#039;CLERK&#039;;<br \/>\n&#8211;WHERE JOB NOT IN (&#039;MANAGER&#039;,&#039;CLERK&#039;) <\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\"><span style=\"background-color:#ffffff\">\u4f8b\u9898&#xff1a;\u627e\u51fa \u6240\u6709 <\/span><span style=\"background-color:#ffffff\">10<\/span><span style=\"background-color:#ffffff\">\u53f7\u90e8\u95e8 \u4ee5\u53ca <\/span><span style=\"background-color:#ffffff\">20<\/span><span style=\"background-color:#ffffff\">\u00a0\u53f7\u90e8\u95e8 \u4ee5\u53ca \u85aa\u8d44 \u4e0d\u5728 <\/span><span style=\"background-color:#ffffff\">2000<\/span><span style=\"background-color:#ffffff\">\u00a0~ <\/span><span style=\"background-color:#ffffff\">3000\u00a0\u8fd9\u4e2a\u533a\u95f4\u7684\u5458\u5de5\u4fe1\u606f\u3002\u8f93\u51fa&#xff1a;ENAME,SAL,DEPTNO\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211;IN&#xff08;X,Y,Z\u2026&#xff09;<\/span><\/span><\/p>\n<p>SELECT ENAME, SAL, DEPTNO<br \/>\nFROM EMP<br \/>\nWHERE DEPTNO IN (10, 20)<br \/>\n  AND SAL NOT BETWEEN 2000 AND 3000; <\/p>\n<h3 id=\"11.LIKE%E6%A8%A1%E7%B3%8A%E6%9F%A5%E8%AF%A2\">11.LIKE<span style=\"color:null\"><span style=\"background-color:#ffffff\">\u6a21\u7cca\u67e5\u8be2<\/span><\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\"><span style=\"background-color:null\">\u5173\u952e\u5b57\u662f LIKE\u00a0(\u957f\u7684\u50cf&#8230;) \u4e24\u4e2a \u901a\u914d\u7b26 <\/span><\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\"><span style=\"background-color:null\">\u00a0% &#xff1a;\u8868\u793a 0\u4f4d\u4ee5\u53ca\u4ee5\u4e0a\u4efb\u610f\u5b57\u7b26 \u00a0\u00a0<\/span><\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\"><span style=\"background-color:null\">\u00a0_ \u00a0\u4e0b\u5212\u7ebf\u8868\u793a \u00a0\u56fa\u5b9a\u4e00\u4f4d\u5b57\u7b26 \u00a0<\/span><\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\"><span style=\"background-color:#ffffff\">\u793a\u4f8b&#xff1a;\u67e5\u8be2EMP\u8868\u4e2d\u59d3\u540d\u5305\u542bS\u7684\u5458\u5de5\u4fe1\u606f<\/span><\/span><\/p>\n<p>SELECT *<br \/>\nFROM EMP<br \/>\n&#8211;WHERE ENAME LIKE &#039;%S%&#039;<br \/>\n&#8211;WHERE ENAME LIKE &#039;%S&#039;<br \/>\nWHERE ENAME LIKE &#039;S%&#039;; <\/p>\n<p><span style=\"color:null\"><span style=\"background-color:#ffffff\">\u793a\u4f8b&#xff1a;\u627e\u51fa \u59d3\u540d\u662f S\u5f00\u5934 \u4e14\u662f\u4e94\u4f4d\u957f\u5ea6\u7684\u5458\u5de5\u59d3\u540d<\/span>\u00a0<\/span><\/p>\n<p>SELECT ENAME<br \/>\nFROM EMP<br \/>\nWHERE ENAME LIKE &#039;S%&#039;<br \/>\n  AND LENGTH(ENAME) &#061; 5; &#8211;\u4e94\u4f4d\u957f\u5ea6<\/p>\n<p>SELECT ENAME<br \/>\nFROM EMP<br \/>\nWHERE ENAME LIKE &#039;S____&#039;; &#8212; 4\u4e2a_ <\/p>\n<p>\u67e5\u8be2\u51fa\u540d\u5b57\u662f5\u4e2a\u5b57&#xff0c;\u5e76\u4e14\u7b2c\u4e8c\u4e2a\u5b57\u6bcd\u662fC\u7684<\/p>\n<p>SELECT ENAME<br \/>\nFROM EMP<br \/>\n&#8211;WHERE ENAME LIKE &#039;_C___&#039;<br \/>\nWHERE LENGTH(ENAME) &#061; 5  &#8211;5\u4f4d\u957f\u5ea6<br \/>\nAND ENAME LIKE &#039;_C%&#039;; <\/p>\n<h3 id=\"12.%E7%A9%BA%E5%80%BCNULL\">12.\u7a7a\u503cNULL<\/h3>\n<h4 id=\"(1)%E7%A9%BA%E5%80%BC%E7%9A%84%E8%BF%87%E6%BB%A4\" style=\"margin-left:0.0001pt;margin-right:0px;text-align:left\"><span style=\"color:null\"><span style=\"background-color:#ffffff\">(1)\u7a7a\u503c\u7684\u8fc7\u6ee4 <\/span><\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\"><span style=\"background-color:#ffffff\">\u9700\u8981 \u7528 <\/span><span style=\"background-color:#ffffff\">IS<\/span>\u00a0<span style=\"background-color:#ffffff\">NULL<\/span><span style=\"background-color:#ffffff\">\u00a0\/ IS<\/span>\u00a0<span style=\"background-color:#ffffff\">NOT<\/span>\u00a0<span style=\"background-color:#ffffff\">NULL\u6765\u5224\u65ad<\/span><\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\"><span style=\"background-color:null\">\u793a\u4f8b&#xff1a;\u7b5b\u9009 \u5956\u91d1\u4e3a \u7a7a(\u6ca1\u6709\u5956\u91d1) \u7684\u5458\u5de5\u4fe1\u606f<\/span><\/span><\/p>\n<p>SELECT\u00a0* FROM\u00a0EMP WHERE\u00a0COMM IS\u00a0NULL; <\/p>\n<h4 id=\"(2)%E7%A9%BA%E5%80%BC%E7%9A%84%E6%8E%92%E5%BA%8F\">(2)\u7a7a\u503c\u7684\u6392\u5e8f<\/h4>\n<p>\u7a7a\u503c\u6392\u5e8f\u6c38\u8fdc\u5728\u6700\u5927<\/p>\n<p>SELECT * FROM EMP ORDER BY COMM; <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"162\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521023438-682d3bbe1eb97.png\" width=\"656\" \/><\/p>\n<p><span style=\"color:#fe2c24\">&#8211;NULLS LAST \u6700\u540e &#8211;NULLS FIRST \u6700\u524d<\/span><\/p>\n<p>SELECT * FROM EMP ORDER BY COMM NULLS first; <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"263\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521023438-682d3bbe2e742.png\" width=\"524\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\"><span style=\"background-color:null\">\u793a\u4f8b&#xff1a;\u627e\u51fa\u6240\u6709\u6ca1\u6709\u5956\u91d1\u7684\u5458\u5de5&#xff0c;\u8f93\u51fa\u5458\u5de5\u59d3\u540d \u00a0\u85aa\u8d44 \u00a0\u90e8\u95e8\u7f16\u53f7&#xff0c;\u5956\u91d1&#xff0c;\u5e76\u4e14\u6309\u7167\u85aa\u8d44\u7684\u964d\u5e8f\u6392\u5e8f<\/span><\/span><\/p>\n<p>SELECT ENAME, SAL, DEPTNO, comm<br \/>\nFROM EMP<br \/>\nWHERE COMM IS NULL<br \/>\n   or comm &#061; 0<br \/>\n&#8211;WHERE nvl(comm,0)&#061;0<br \/>\nORDER BY SAL DESC; <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"220\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521023438-682d3bbe42321.png\" width=\"278\" \/><\/p>\n<h4 id=\"(3)%E7%A9%BA%E5%80%BC%E8%BF%90%E7%AE%97\"><span style=\"color:null\">(3)\u7a7a\u503c\u8fd0\u7b97<\/span><\/h4>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ff0000\"><span style=\"background-color:null\">&#8212; \u7a7a\u503c\u4e0d\u53c2\u4e0e\u6bd4\u8f83\u8fd0\u7b97<\/span><\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:#ff0000\"><span style=\"background-color:null\">&#8212; \u7a7a\u503c\u8ddf\u4efb\u4f55\u503c \u8fdb\u884c \u52a0\u51cf\u4e58\u9664 \u90fd\u662f\u5f97\u5230 \u7a7a(NULL)<\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"168\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521023438-682d3bbe53a7f.png\" width=\"655\" \/><\/p>\n<h4 id=\"(4)%E7%A9%BA%E5%80%BC%E8%BD%AC%E6%8D%A2NVL%E4%B8%8ENVL2\" style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:null\"><span style=\"background-color:#ffffff\">(4)\u7a7a\u503c\u8f6c\u6362<\/span><\/span>NVL\u4e0eNVL2<\/h4>\n<p>NVL(expr1, expr2) <\/p>\n<p>\u5982\u679c\u00a0expr1\u00a0\u4e3a\u975e NULL&#xff0c;\u5219\u8fd4\u56de\u00a0expr1&#xff1b;\u5982\u679c\u00a0expr1\u00a0\u4e3a NULL&#xff0c;\u5219\u8fd4\u56de\u00a0expr2\u3002<\/p>\n<p>NVL2(\u8868\u8fbe\u5f0f,\u4e0d\u4e3a\u7a7a\u8bbe\u503c,\u4e3a\u7a7a\u8bbe\u503c)<br \/>\nSELECT NVL(comm, 0) FROM EMP;<br \/>\nSELECT NVL2(null, 1, 0) FROM dual; <\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\"><span style=\"background-color:#ffffff\">\u793a\u4f8b&#xff1a;\u627e\u51fa\u5e74\u6536\u5165\u9ad8\u4e8e3\u4e07\u7684\u5458\u5de5\u4fe1\u606f(\u5e74\u6536\u5165 &#061; (\u85aa\u8d44&#043;\u5956\u91d1) * <\/span><span style=\"background-color:#ffffff\">12)&#xff0c;<\/span><\/span><span style=\"color:null\"><span style=\"background-color:#ffffff\">\u5e76\u4e14\u8f93\u51fa\u5458\u5de5\u59d3\u540d\u3001\u5458\u5de5\u85aa\u8d44\u3001\u5956\u91d1\u3001\u5e74\u6536\u5165\u3002<\/span><\/span><span style=\"color:null\"><span style=\"background-color:#ffffff\">\u6309\u7167\u5e74\u6536\u5165\u7684\u5012\u5e8f\u6392\u5e8f\u3002<\/span><\/span><\/p>\n<p>select ename<br \/>\n     , sal<br \/>\n     , nvl(comm, 0)<br \/>\n     , 12 * (sal &#043; nvl(comm, 0)) year_sal&#8211;\u5e74\u6536\u5165<br \/>\nfrom emp<br \/>\nwhere 12 * (sal &#043; nvl(comm, 0)) &gt; 30000&#8211;\u5e74\u6536\u5165\u9ad8\u4e8e3\u4e07<br \/>\norder by year_sal desc; <\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:left\"><span style=\"color:null\"><span style=\"background-color:null\">\u603b\u7ed3&#xff1a;<\/span><\/span><\/p>\n<ul>\n<li style=\"margin-left:0.0001pt;text-align:left\"><span style=\"color:null\"><span style=\"background-color:null\">\u7a7a\u503c&#xff1a;\u672a\u77e5\u7684 \u6ca1\u6709\u610f\u601d\u7684\u6570 \u4e0d\u662f0 \u4e5f\u4e0d\u662f\u7a7a\u683c<\/span><\/span><\/li>\n<li style=\"margin-left:0.0001pt;text-align:left\"><span style=\"color:null\"><span style=\"background-color:null\">NULL<\/span><\/span><span style=\"color:null\"><span style=\"background-color:null\">\u6392\u5e8f\u5728\u6700\u5927<\/span><\/span><\/li>\n<li style=\"margin-left:0.0001pt;text-align:left\"><span style=\"color:null\"><span style=\"background-color:null\">\u5bf9 null\u00a0\u505a&#043;-*\/\u8fd0\u7b97\u5f97\u5230\u7684\u8fd8\u662f NULL<\/span><\/span><\/li>\n<li style=\"margin-left:0.0001pt;text-align:justify\"><span style=\"color:null\"><span style=\"background-color:null\">NULL\u00a0\u4e0d\u53c2\u4e0e\u6bd4\u8f83<\/span><\/span><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb326\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u4ecb\u7ecdOracle\u4f7f\u7528\u7684\u57fa\u7840\u77e5\u8bc6<\/p>\n","protected":false},"author":2,"featured_media":38734,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[604,768,100],"topic":[],"class_list":["post-38742","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-oracle","tag-sql","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Oracle\u57fa\u7840\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/38742.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Oracle\u57fa\u7840\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb326\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u4ecb\u7ecdOracle\u4f7f\u7528\u7684\u57fa\u7840\u77e5\u8bc6\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/38742.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-21T02:34:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521023437-682d3bbdd9802.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/38742.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/38742.html\",\"name\":\"Oracle\u57fa\u7840\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-21T02:34:39+00:00\",\"dateModified\":\"2025-05-21T02:34:39+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/38742.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/38742.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/38742.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Oracle\u57fa\u7840\u77e5\u8bc6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Oracle\u57fa\u7840\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/38742.html","og_locale":"zh_CN","og_type":"article","og_title":"Oracle\u57fa\u7840\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb326\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u4ecb\u7ecdOracle\u4f7f\u7528\u7684\u57fa\u7840\u77e5\u8bc6","og_url":"https:\/\/www.wsisp.com\/helps\/38742.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-21T02:34:39+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250521023437-682d3bbdd9802.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/38742.html","url":"https:\/\/www.wsisp.com\/helps\/38742.html","name":"Oracle\u57fa\u7840\u77e5\u8bc6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-21T02:34:39+00:00","dateModified":"2025-05-21T02:34:39+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/38742.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/38742.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/38742.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Oracle\u57fa\u7840\u77e5\u8bc6"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/38742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=38742"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/38742\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/38734"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=38742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=38742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=38742"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=38742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}