| PostgreSQL 8.0.0 �����ĵ���PostgreSQL �й� ������ | ||||
|---|---|---|---|---|
| Prev | Fast Backward | Chapter 9. �����Ͳ����� | Fast Forward | Next | 
PostgreSQL Ϊ��������ṩ����ѧ�������� ������Щ�����п��ܵ�����ж�û��һ�����ѧ��ͳ������ (���磬����/ʱ������)�������������½�������ʵ�ʵ���Ϊ��
Table 9-2 ��ʾ�˿��õ���ѧ��������
Table 9-2. ��ѧ������
| ������ | ���� | ���� | ��� | 
|---|---|---|---|
| + | �� | 2 + 3 | 5 | 
| - | �� | 2 - 3 | -1 | 
| * | �� | 2 * 3 | 6 | 
| / | �� �������������ضϽ���� | 4 / 2 | 2 | 
| % | ģ�� �����ࣩ | 5 % 4 | 1 | 
| ^ | �ݣ�ָ�����㣩 | 2.0 ^ 3.0 | 8 | 
| |/ | ƽ���� | |/ 25.0 | 5 | 
| ||/ | ������ | ||/ 27.0 | 3 | 
| ! | �׳� | 5 ! | 120 | 
| !! | �׳� ��ǰ������ | !! 5 | 120 | 
| @ | ����ֵ | @ -5.0 | 5 | 
| & | ������ AND | 91 & 15 | 11 | 
| | | ������ OR | 32 | 3 | 35 | 
| # | ������ XOR | 17 # 5 | 20 | 
| ~ | ������ NOT | ~1 | -2 | 
| << | ���������� | 1 << 4 | 16 | 
| >> | ���������� | 8 >> 2 | 2 | 
��λ����������ֻ�����������������ͣ��������IJ�������������ȫ����ֵ�������͡� ��λ�����IJ���������������λ������ bit �� bit varying�� �� Table 9-10 ��ʾ��
Table 9-3 ��ʾ�˿��õ���ѧ������ �ڸñ��У�dp ��ʾdouble precision�� ��Щ�����������ж��ֲ�ͬ����ʽ�������Dz�����ͬ�� �����ر�ָ�����κ��ض���ʽ�ĺ��������غ����IJ�����ͬ���������͡� ���� double precision ���ݵĺ������������ ����ϵͳ�� C ��Ļ�����ʵ�ֵģ���ˣ�ȷ�Ⱥ� ��ֵ��Χ�������Ϊ�Ǹ�������ϵͳ���仯�ġ�
Table 9-3. ��ѧ����
| ���� | �������� | ���� | ���� | ��� | 
|---|---|---|---|---|
| abs(x) | ����x������ͬ�� | ����ֵ | abs(-17.4) | 17.4 | 
| cbrt(dp) | dp | ������ | cbrt(27.0) | 3 | 
| ceil(dp ���� numeric) | ��������ͬ | ��С�ڲ�������С������ | ceil(-42.8) | -42 | 
| ceiling(dp or numeric) | ����������ͬ�� | ��С�ڲ�������С������ceil �ı����� | ceiling(-95.3) | -95 | 
| degrees(dp) | dp | �ѻ���תΪ�Ƕ� | degrees(0.5) | 28.6478897565412 | 
| exp(dp �� numeric) | ��������ͬ | ��Ȼָ�� | exp(1.0) | 2.71828182845905 | 
| floor(dp �� numeric) | ��������ͬ | �����ڲ������������ | floor(-42.8) | -43 | 
| ln(dp �� numeric) | ��������ͬ | ��Ȼ���� | ln(2.0) | 0.693147180559945 | 
| log(dp �� numeric) | ��������ͬ | 10 Ϊ�Ķ��� | log(100.0) | 2 | 
| log(b numeric, x numeric) | numeric | ָ�������Ķ��� | log(2.0, 64.0) | 6.0000000000 | 
| mod(y, x) | (�Ͳ���������ͬ) | ���� y/x ��������ģ�� | mod(9,4) | 1 | 
| pi() | dp | "π" ���� | pi() | 3.14159265358979 | 
| power(a dp, b dp) | dp | ��a�� b ���� | power(9.0, 3.0) | 729 | 
| power(a numeric, b numeric) | numeric | ��a�� b ���� | power(9.0, 3.0) | 729 | 
| radians(dp) | dp | �ѽǶ�תΪ���� | radians(45.0) | 0.785398163397448 | 
| random() | dp | 0.0 �� 1.0 ֮��������ֵ | random() | |
| round(dp ���� numeric) | ����������ͬ�� | Բ��Ϊ��ӽ������� | round(42.4) | 42 | 
| round(v numeric, s integer) | numeric | Բ��ΪsλС������ | round(42.4382, 2) | 42.44 | 
| setseed(dp) | integer | ���� random() ������������ | setseed(0.54823) | 1177314959 | 
| sign(dp ���� numeric) | ����������ͬ�� | �����ķ��ţ�-1, 0, +1�� | sign(-8.4) | -1 | 
| sqrt(dp ���� numeric) | ����������ͬ�� | ƽ���� | sqrt(2.0) | 1.4142135623731 | 
| trunc(dp ���� numeric) | ����������ͬ�� | �ضϣ����㿿���� | trunc(42.8) | 42 | 
| trunc(v numeric, s integer) | numeric | �ض�Ϊ s С��λ�õ����� | trunc(42.4382, 2) | 42.43 | 
| width_bucket(op numeric, b1 numeric, b2 numeric, count integer) | integer | ����һ��Ͱ�����Ͱ����һ���� count ��Ͱ�� �Ͻ�Ϊ b1���½�Ϊ b2 �ĵ�����ͼ�� operand ����������Ǹ�Ͱ�� | width_bucket(5.35, 0.024, 10.06, 5) | 3 | 
���Table 9-4 ��ʾ�˿��õ����Ǻ����� �������Ǻ�����������Ϊ double precision �IJ����ͷ������͡�