-
-
String Functions
+
+
String Functions
-SQL92 defines string functions with specific syntax. Some of these
-are implemented using other
Postgres functions.
-
+ SQL92 defines string functions with specific syntax. Some of these
+ are implemented using other
Postgres functions.
+ The supported string types for
SQL92 are
+ char, varchar, and text.
+
-
-
-
- |
- Function
- Returns
- Description
- Example
-
-
-
- |
- position(text in text)
- int4
- location of specified substring
- position('o' in 'Tom')
-
- |
- substring(text [from int] [for int])
- text
- extract specified substring
- substring('Tom' from 2 for 2)
-
- |
- trim([leading|trailing|both] [text] from text)
- text
- trim characters from text
- trim(both 'x' from 'xTomx')
-
-
-
-
-
+
+
+
+ |
+ Function
+ Returns
+ Description
+ Example
+
+
+
+ |
+ char_length(string)
+ int4
+ length of string
+ char_length('jose')
+
+ |
+ character_length(string)
+ int4
+ length of string
+ char_length('jose')
+
+ |
+ lower(string)
+ string
+ convert string to lower case
+ lower('TOM')
+
+ |
+ octet_length(string)
+ int4
+ storage length of string
+ octet_length('jose')
+
+ |
+ position(string in string)
+ int4
+ location of specified substring
+ position('o' in 'Tom')
+
+ |
+ substring(string [from int] [for int])
+ string
+ extract specified substring
+ substring('Tom' from 2 for 2)
+
+ |
+ trim([leading|trailing|both] [string] from string)
+ string
+ trim characters from string
+ trim(both 'x' from 'xTomx')
+
+ |
+ upper(text)
+ text
+ convert text to upper case
+ upper('tom')
+
+
+
+
+
-Many string functions are available for text, varchar(), and char() types.
-Some are used internally to implement the SQL92 string functions listed above.
-
+ Many additional string functions are available for text, varchar(), and char() types.
+ Some are used internally to implement the SQL92 string functions listed above.
+
initcap('thomas')
|
- lower(text)
- text
- convert text to lower case
- lower('TOM')
-
- |
lpad(text,int,text)
text
left pad string to specified length
ltrim('xxxxtrim','x')
|
- position(text,text)
+ textpos(text,text)
text
- extract specified substring
+ locate specified substring
position('high','ig')
|
convert text to varchar type
varchar('text string')
- |
- upper(text)
- text
- convert text to upper case
- upper('tom')
-
+