Oracle替换函数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle替换函数相关的知识,希望对你有一定的参考价值。
A few examples of the Oracle REPLACE function
/*REPLACE*/ /*Example 1*/ SELECT 'Today is the 26th of February, 2015' AS ORIGINAL_STRING, REPLACE('Today is the 26th of February, 2015', 'a', 'X') AS REPLACE_STRING FROM dual; /*Example 2*/ SELECT 'Today is the 26th of February, 2015' AS ORIGINAL_STRING, REPLACE('Today is the 26th of February, 2015', 'the', 'probably the') AS REPLACE_STRING FROM dual; /*Example 3*/ SELECT 'Today is the 26th of February, 2015' AS ORIGINAL_STRING, REPLACE('Today is the 26th of February, 2015', 'th') AS REPLACE_STRING FROM dual; /*Example 4*/ SELECT 'Today is the 26th of February, 2015' AS ORIGINAL_STRING, REPLACE('Today is the 26th of February, 2015', 'X', 'Y') AS REPLACE_STRING FROM dual; /*Example 5*/ SELECT 'Today is the 26th of February, 2015' || CHR(13) AS ORIGINAL_STRING, REPLACE('Today is the 26th of February, 2015' || CHR(13), CHR(13), ' ') AS REPLACE_STRING FROM dual; /*Example 6*/ SELECT 'Today is the 26th of February, 2015' || CHR(13) || CHR(10) AS ORIGINAL_STRING, REPLACE('Today is the 26th of February, 2015' || CHR(13) || CHR(10), CHR(13) || CHR(10), ' ') AS REPLACE_STRING FROM dual; /*Example 7*/ SELECT NULL AS ORIGINAL_STRING, REPLACE(NULL, NULL, 'x') AS REPLACE_STRING FROM dual; /*Example 8*/ SELECT 'My first name is (x), my last name is (y), and I am from (z).' AS ORIGINAL_STRING, REPLACE(REPLACE(REPLACE('My first name is (x), my last name is (y), and I am from (z).', '(x)', 'John'), '(y)', 'Smith'), '(z)', 'England') AS REPLACE_STRING FROM dual; /*Example 9*/ SELECT 'What''s the date today?' AS ORIGINAL_STRING, REPLACE('What''s the date today?', '''', '"') AS REPLACE_STRING FROM dual; /*Example 10*/ SELECT 'What''s the date today?' AS ORIGINAL_STRING, REPLACE('What''s the date today?', '''') AS REPLACE_STRING FROM dual;
以上是关于Oracle替换函数的主要内容,如果未能解决你的问题,请参考以下文章