9.5. �������ִ������Ͳ�����

����������Щ���Ͳ�������Ϊ bytea ����ֵ�ĺ����Ͳ�������

SQL ������һЩ�������﷨���ִ������� ����Щ������ʹ������ؼ��ֶ����Ƕ������ָ������� ������� Table 9-8�� һЩ����Ҳʵ����ʹ�ó����﷨���к������õķ����� (���� Table 9-9��)

Table 9-8. SQL �������ִ������Ͳ�����

�����������������������
string || string bytea �ִ����� '\\\\Post'::bytea || '\\047gres\\000'::bytea\\Post'gres\000
octet_length(string)integer�������ִ��е��ֽ���Ŀoctet_length('jo\\000se'::bytea)5
position(substring in string)integerָ�����ִ���λ��position('\\000om'::bytea in 'Th\\000omas'::bytea)3
substring(string [from integer] [for integer])bytea ��ȡ���ִ� substring('Th\\000omas'::bytea from 2 for 3)h\000o
trim([both] bytes from string) bytea �� string �Ŀ�ͷ�ͽ�βɾ�� ֻ���� bytes ������ִ��� trim('\\000'::bytea from '\\000Tom\\000'::bytea)Tom
get_byte(string, offset)integer ���ִ��г�ȡ�ֽڡ� get_byte('Th\\000omas'::bytea, 4)109
set_byte(string, offset, newvalue)bytea �����ִ��е��ֽڡ� set_byte('Th\\000omas'::bytea, 4, 64)Th\000o@as
get_bit(string, offset)integer ���ִ��г�ȡλ�� get_bit('Th\\000omas'::bytea, 45)1
set_bit(string, offset, newvalue)bytea �����ִ��е�λ�� set_bit('Th\\000omas'::bytea, 45, 0)Th\000omAs

����һЩ�������ִ�����������ʹ�ã���Table 9-9�г��� ������һЩ�����ڲ�ʹ�ã�����ʵ��Table 9-8�г��� SQL ��׼���ִ������ġ�

Table 9-9. �����������ִ�����

�����������������������
btrim(string bytea, bytes bytea)bytea �� string �Ŀ�ͷ�ͽ�βɾ��(�ض�) ֻ������ bytes ������ֽڵ�����ִ��� btrim('\\000trim\\000'::bytea,'\\000'::bytea)trim
length(string)integer �������ִ��ij��� length('jo\\000se'::bytea)5
decode(string text, type text) bytea ��ǰ����encode()����ķ��� string ��� �������ִ����롣�������ͺ�encode()���һ���� decode('123\\000456', 'escape')123\000456
encode(string bytea, type text) text �Ѷ������ִ�����Ϊֻ���� ASCII �ı�����ʽ�� �����ǡ� base64��hex��escape�� encode('123\\000456'::bytea, 'escape')123\000456