×
☰ See All Chapters

Oracle LENGTH Function

Oracle LENGTH function returns an integer value that represents the number of characters in the string.

Oracle LENGTH Function Syntax

LENGTH(arg)

arg is the argument for which you want get the length. This can be an expression or a direct value or a value from a column of any type.

Oracle LENGTH Function Example

Creating table for demonstrating LENGTH Function

CREATE TABLE NAME

(

  FNAME  VARCHAR(10 )    NOT NULL,

  LNAME  VARCHAR(10 )

);

Insert into NAME (FNAME, LNAME) Values ('ADI', 'TEMP');

Insert into NAME (FNAME, LNAME) Values ('NAVEEN', 'SHETTY');

Insert into NAME (FNAME, LNAME) Values ('ARJUN', 'SHETTY');

Insert into NAME (FNAME, LNAME) Values ('HARISH', 'GOWDA');

Insert into NAME (FNAME, LNAME) Values ('HARI', 'PRASAD');

Insert into NAME (FNAME, LNAME) Values ('ARJUN', 'SHETTY');

Insert into NAME (FNAME, LNAME) Values ('KIRAN', 'KUMAR');

COMMIT;

Example 1

SELECT LENGTH(FNAME), LENGTH(LNAME)

FROM NAME

oracle-length-function-0

Example 2

SELECT FNAME, LNAME, LENGTH(CONCAT(FNAME,LNAME)) AS NAME_LENGTH

FROM NAME

oracle-length-function-1


All Chapters
Author