The initcap function in GBase 8a capitalizes the first letter of each word in a string and converts the rest to lowercase. It's a handy tool for normalising names, titles, and other text fields in a gbase database.
Syntax
INITCAP(expr)
-
expr: a string expression — a column, a literal, or a function result. - Letters are determined by the Unicode Letter category, covering English, pinyin, Chinese characters, Japanese kana, and Western European letters.
- Words are delimited by spaces, tabs, newlines, full‑width spaces, and punctuation marks (commas, hyphens, underscores, etc.).
Examples
Basic English Text
gbase> SELECT INITCAP('hello wORLD');
+------------------------+
| INITCAP('hello wORLD') |
+------------------------+
| Hello World |
+------------------------+
Full‑Width Pinyin
Full‑width letters are treated the same way.
gbase> SELECT INITCAP('abc');
+----------------------+
| INITCAP('abc') |
+----------------------+
| Abc |
+----------------------+
Various Delimiters
initcap recognises a wide range of separators, so words split by punctuation, hyphens, underscores, or full‑width spaces are each capitalised independently.
gbase> SELECT INITCAP('hello,wORLD');
+------------------------+
| INITCAP('hello,wORLD') |
+------------------------+
| Hello,World |
+------------------------+
gbase> SELECT INITCAP('hello-wORLD');
+------------------------+
| INITCAP('hello-wORLD') |
+------------------------+
| Hello-World |
+------------------------+
gbase> SELECT INITCAP('hello_wORLD');
+------------------------+
| INITCAP('hello_wORLD') |
+------------------------+
| Hello_World |
+------------------------+
initcap is a simple yet powerful string formatting function in GBase 8a. Use it whenever you need to present text in a consistent, capitalised format directly within your SQL queries.
Top comments (0)