Introduction
Concatenation
Simple text functions
11. Function initcap
How to modify strings
Revision

Instruction

Nice! Yet another function is initcap(), which will change the first letter of a text value to upper case and the rest to lower case. For instance, if someone mistakenly inserted another lastname with caps lock as 'sMITH', the query:

SELECT initcap(last_name)
FROM copywriter
will show 'Smith' for that last name. That's often a convenient way to show all names in the proper way.

The initcap() is only present in PostgreSQL and Oracle. It does not exist in MySQL and SQL Server.

Exercise

The boss wants you to update the names of all the items so that they start with a capital letter, followed by lower case. Show the id of each item together with its old name and new name.

Stuck? Here's a hint!

Use initcap(name).

Console

Code editor

Result

TableConsole