In Oracle, the LOWER()
function returns its argument with all letters in lowercase.
Syntax
The syntax goes like this:
LOWER(char)
Where char
can be of any of the data types CHAR
, VARCHAR2
, NCHAR
, NVARCHAR2
, CLOB
, or NCLOB
.
Example
Here’s a simple example to demonstrate:
SELECT LOWER('NEW ZEALAND')
FROM DUAL;
Result:
LOWER('NEWZEALAND') ______________________ new zealand
The same applies when the argument uses mixed case:
SELECT LOWER('New Zealand')
FROM DUAL;
Result:
LOWER('NEWZEALAND') ______________________ new zealand
And if the argument is already lowercase, then the result is the same as the input:
SELECT LOWER('new zealand')
FROM DUAL;
Result:
LOWER('NEWZEALAND') ______________________ new zealand
Null Values
Passing null
returns null
:
SET NULL 'null';
SELECT LOWER(null)
FROM DUAL;
Result:
LOWER(NULL) ______________ null
By default, SQLcl and SQL*Plus return a blank space whenever null
occurs as a result of a SQL SELECT
statement.
However, you can use SET NULL
to specify a different string to be returned. Here I specified that the string null
should be returned.
Incorrect Argument Count
Calling LOWER()
without passing any arguments returns an error:
SELECT LOWER()
FROM DUAL;
Result:
Error starting at line : 1 in command - SELECT LOWER() FROM DUAL Error at Command Line : 1 Column : 8 Error report - SQL Error: ORA-00909: invalid number of arguments 00909. 00000 - "invalid number of arguments" *Cause: *Action:
And passing the wrong number of arguments results in an error:
SELECT LOWER('New', 'Zealand')
FROM DUAL;
Result:
Error starting at line : 1 in command - SELECT LOWER('New', 'Zealand') FROM DUAL Error at Command Line : 1 Column : 8 Error report - SQL Error: ORA-00909: invalid number of arguments 00909. 00000 - "invalid number of arguments" *Cause: *Action: