| Documentation PostgreSQL 7.2 | ||
|---|---|---|
| <<< Previous | Fonctions et Opérateurs | Next >>> |
Cette section décrit les fonctions et les opérateurs pour l'examen et la manipulation des valeurs chaîne binaire. Les chaînes dans ce contexte incluent toutes les valeurs du type BYTEA.
SQL définit certaines fonctions chaîne avec une syntaxe spéciale où certains mots-clé davantage que les virgules sont utilisés pour séparer les arguments. Voir les détails en Table 8. Certaines fonctions sont aussi implémentées en utilisant la syntaxe normale de l'invocation de fonction. (Voir Table 9.)
Table 8. Fonctions et opérateurs chaîne binaire SQL
| Fonction | Retour | Description | Exemple | Résultat |
|---|---|---|---|---|
| string || string | bytea | string concatenation | '\\\\Postgre'::bytea || '\\047SQL\\000'::bytea | \\Postgre'SQL\000 |
| octet_length(string) | integer | number of bytes in binary string | octet_length('jo\\000se'::bytea) | 5 |
| position(substring in string) | integer | location of specified substring | position('\\000om'::bytea in 'Th\\000omas'::bytea) | 3 |
| substring(string [from integer] [for integer]) | bytea | extract substring | substring('Th\\000omas'::bytea from 2 for 3) | h\000o |
| trim([both] characters from string) | bytea | Removes the longest string containing only the characters from the beginning/end/both ends of the string. | trim('\\000'::bytea from '\\000Tom\\000'::bytea) | Tom |
Des fonctions de manipulation de chaîne binaire supplémentaires sont disponibles et listées plus bas. Certaines d'entre elles sont utilisées en interne pour implémenter les fonctions chaîne SQL-standard citées ci-dessous.
Table 9. Autres fonctions chaîne binaire
| Fonction | Retour | Description | Exemple | Résultat |
|---|---|---|---|---|
| btrim(string bytea, trim bytea) | bytea | Remove (trim) the longest string consisting only of characters in trim from the start and end of string. | btrim('\\000trim\\000'::bytea,'\\000'::bytea) | trim |
| length(string) | integer | length of binary string | length('jo\\000se'::bytea) | 5 |
| encode(string bytea, type text) | text | Encodes binary string to ASCII-only representation. Supported types are: 'base64', 'hex', 'escape'. | encode('123\\000456'::bytea, 'escape') | 123\000456 |
| decode(string text, type text) | bytea | Decodes binary string from string previously encoded with encode(). Parameter type is same as in encode(). | decode('123\\000456', 'escape') | 123\000456 |
| <<< Previous | Home | Next >>> |
| Opérateurs et fonctions chaîne | Up | Filtrage |