Hey StackExchange
Hey StackExchange

Reputation: 2125

Oracle 10g: truncate string

I'm having a query that append a string value from multiple rows and insert the result in a new table.

I would like to limit the String length that is inserted.

Question

What is the best way to achieve that : Should I use SUBSTR or SUBSTRB or is there a better way ?

Upvotes: 2

Views: 38421

Answers (1)

Jacob
Jacob

Reputation: 14731

Using SQL you can use SUBSTR function to get the character limit

SELECT SUBSTR (test_string, 0, 10) FROM table_name

E.g.

SELECT  SUBSTR ('Testing1/testing2', 0, 10) FROM dual

Using LENGTH function, you will be able to ascertain the count of the string

SELECT  LENGTH ('Testing1/testing2') FROM dual

Upvotes: 7

Related Questions