Oracle PL/SQL/Char Functions/RTRIM
Содержание
Rtrim char type column data
<source lang="sql">
SQL> SQL> CREATE TABLE old_item (
2 item_id CHAR(20), 3 item_desc CHAR(25) 4 );
Table created. SQL> SQL> INSERT INTO old_item VALUES("LA-101", "Can, Small"); 1 row created. SQL> INSERT INTO old_item VALUES("LA-102", "Can, Large"); 1 row created. SQL> INSERT INTO old_item VALUES("LA-103", "Bottle, Small"); 1 row created. SQL> INSERT INTO old_item VALUES("LA-104", "Bottle, Large"); 1 row created. SQL> INSERT INTO old_item VALUES("NY-101", "Box, Small"); 1 row created. SQL> INSERT INTO old_item VALUES("NY-102", "Box, Large"); 1 row created. SQL> INSERT INTO old_item VALUES("NY-103", "Shipping Carton, Small"); 1 row created. SQL> INSERT INTO old_item VALUES("NY-104", "Shipping Carton, Large"); 1 row created. SQL> SQL> SQL> SELECT "Item " ||
2 RTRIM(item_id) || 3 " is described as a " || 4 RTRIM(item_desc) || 5 "." "Item Description Sentence" 6 FROM old_item;
Item Description Sentence
Item LA-101 is described as a Can, Small. Item LA-102 is described as a Can, Large. Item LA-103 is described as a Bottle, Small. Item LA-104 is described as a Bottle, Large. Item NY-101 is described as a Box, Small. Item NY-102 is described as a Box, Large. Item NY-103 is described as a Shipping Carton, Small. Item NY-104 is described as a Shipping Carton, Large. 8 rows selected. SQL> SQL> drop table OLD_ITEM; Table dropped. SQL>
</source>
RTRIM function removes trailing characters
<source lang="sql">
SQL> --RTRIM function removes trailing characters. SQL> SQL> SELECT RTRIM("S" , "STEVENS") AS TRIM FROM Dual; T -
SQL>
</source>
Rtrim: removes a set of characters from the right of a string
<source lang="sql">
SQL> -- RTRIM stands for "right trim." SQL> -- The general format for this function is: SQL> SQL> -- RTRIM(string, characters_to_remove) SQL> SQL> SQL> SELECT RTRIM("Computers", "s") FROM dual; RTRIM("C
Computer
</source>
Use rtim to remove space
<source lang="sql">
SQL> SQL> select """ || rtrim( "Some String " ) || """ "A String"
2 from dual 3 /
A String
"Some String" 1 row selected. SQL> SQL> --
</source>