In this article, I am sharing the steps to get last characters from string in oracle. Suppose we have a value in one of the columns as ‘NarayanaTutorial‘ Then how to get only ‘Tutorial‘ string?
We can achieve this in two different ways as follows.
By using substr function we can get the last characters using the following sql query
SQL> SELECT SUBSTR('NarayanaTutorial', -8) FROM DUAL; Output Tutorial
Minus(-) indicates that it will read string from right to left and get the specified number of characters from right to left.
By using SUBSTR and REVERSE functions we can get the last characters using the following sql query.
SQL> SELECT REVERSE(SUBSTR(REVERSE('NarayanaTutorial'), 1, 8)) FROM DUAL; Output Tutorial
Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in IT industry more than 7 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting and Website Development.
I am a self learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.