# Posted By

bbrumm on 01/15/17

# Statistics

Viewed 537 times
Favorited by 0 user(s)

# Oracle SUBSTR Function

/ Published in: SQL
Save to your folder(s)

A few examples of the Oracle SUBSTR function.

Copy this code and paste it in your HTML
`/* SUBSTR Examples */  /* 1 - Example with Both Parameters */ SELECT 'Complete IT Professional',SUBSTR('Complete IT Professional', 1, 10) AS SUBFROM DUAL; /* 2 - Example with Only Start Position */ SELECT 'Complete IT Professional',SUBSTR('Complete IT Professional', 5) AS SUBFROM DUAL;  /* 3 - Example in Reverse */ SELECT 'Complete IT Professional',SUBSTR('Complete IT Professional', -1, 5) AS SUBFROM DUAL;  /* 4 - Example in Reverse */ SELECT 'Complete IT Professional',SUBSTR('Complete IT Professional', -5, 5) AS SUBFROM DUAL; /* 5 - Example of SUBSTR with INSTR Combined */ SELECT 'Complete IT Professional',SUBSTR('Complete IT Professional',   INSTR('Complete IT Professional', ' ', 1, 1)) AS SUBFROM DUAL;  /* 6 - Example of SUBSTR with INSTR Combined */ SELECT 'Complete IT Professional',SUBSTR('Complete IT Professional', 1,   INSTR('Complete IT Professional', ' ', 1, 1)) AS SUBFROM DUAL;  /* 7 - Example of SUBSTR with INSTR Combined */ SELECT 'Complete IT Professional',SUBSTR('Complete IT Professional',   INSTR('Complete IT Professional', ' ', 1, 1)+1,  INSTR('Complete IT Professional', ' ', 1, 2)-INSTR('Complete IT Professional', ' ', 1, 1)-1) AS SUBFROM DUAL; /* 8 - Example to remove last character */ SELECT 'Complete IT Professional',SUBSTR('Complete IT Professional', 0,   LENGTH('Complete IT Professional') - 1) AS SUBFROM DUAL;  /* 9 - Example to remove last 5 characters */ SELECT 'Complete IT Professional',SUBSTR('Complete IT Professional', 0,   LENGTH('Complete IT Professional') - 5) AS SUBFROM DUAL;`