~ubuntu-branches/ubuntu/lucid/postgresql-8.4/lucid-proposed

« back to all changes in this revision

Viewing changes to doc/FAQ_chinese_simp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-09-06 14:11:13 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090906141113-qf5f3hkw7n036jfy
Tags: 8.4.1-1
* Urgency medium due to security fix.
* New upstream security/bug fix release:
  - Disallow "RESET ROLE" and "RESET SESSION AUTHORIZATION" inside
    security-definer functions. This covers a case that was missed in the
    previous patch that disallowed "SET ROLE" and "SET SESSION
    AUTHORIZATION" inside security-definer functions. [CVE-2007-6600]
  - Fix WAL page header initialization at the end of archive recovery.
    This could lead to failure to process the WAL in a subsequent archive
    recovery.
  - Fix "cannot make new WAL entries during recovery" error.
  - Fix problem that could make expired rows visible after a crash.
    This bug involved a page status bit potentially not being set
    correctly after a server crash.
  - Make "LOAD" of an already-loaded loadable module into a no-op.
    Formerly, "LOAD" would attempt to unload and re-load the module,
    but this is unsafe and not all that useful.
  - Make window function PARTITION BY and ORDER BY items always be
    interpreted as simple expressions.
    In 8.4.0 these lists were parsed following the rules used for
    top-level GROUP BY and ORDER BY lists. But this was not correct per
    the SQL standard, and it led to possible circularity.
  - Fix several errors in planning of semi-joins. These led to wrong query
    results in some cases where IN or EXISTS was used together with another
    join.
  - Fix handling of whole-row references to subqueries that are within
    an outer join. An example is SELECT COUNT(ss.-) FROM ... LEFT JOIN
    (SELECT ...) ss ON .... Here, ss.- would be treated as
    ROW(NULL,NULL,...) for null-extended join rows, which is not the same as
    a simple NULL.  Now it is treated as a simple NULL.
  - Fix locale handling with plperl. This bug could cause the server's
    locale setting to change when a plperl function is called, leading to
    data corruption.
  - Fix handling of reloptions to ensure setting one option doesn't
    force default values for others.
  - Ensure that a "fast shutdown" request will forcibly terminate open
    sessions, even if a "smart shutdown" was already in progress.
  - Avoid memory leak for array_agg() in GROUP BY queries.
  - Treat to_char(..., 'TH') as an uppercase ordinal suffix with
    'HH'/'HH12'.  It was previously handled as 'th'.
  - Include the fractional part in the result of EXTRACT(second) and
    EXTRACT(milliseconds) for time and time with time zone inputs.
    This has always worked for floating-point datetime configurations,
    but was broken in the integer datetime code.
  - Fix overflow for INTERVAL 'x ms' when "x" is more than 2 million
    and integer datetimes are in use.
  - Improve performance when processing toasted values in index scans.
    This is particularly useful for PostGIS.
  - Fix a typo that disabled commit_delay.
  - Output early-startup messages to "postmaster.log" if the server is
    started in silent mode. Previously such error messages were discarded,
    leading to difficulty in debugging.
  - Remove translated FAQs. They are now on the wiki. The main FAQ was moved
    to the wiki some time ago.
  - Fix pg_ctl to not go into an infinite loop if "postgresql.conf" is
    empty.
  - Fix several errors in pg_dump's --binary-upgrade mode. pg_dump
    --binary-upgrade is used by pg_migrator.
  - Fix "contrib/xml2"'s xslt_process() to properly handle the maximum
    number of parameters (twenty).
  - Improve robustness of libpq's code to recover from errors during
    "COPY FROM STDIN".
  - Avoid including conflicting readline and editline header files when
    both libraries are installed.
  - Work around gcc bug that causes "floating-point exception" instead
    of "division by zero" on some platforms.
* debian/control: Bump Standards-Version to 3.8.3 (no changes necessary).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
                          PostgreSQL 常����FAQ�
3
 
                                       
4
 
   �����2007 年 1 � 30 � ��� 17:37:01 EST
5
 
   ��������2007 年 2 � 1 � ��� 12:55:04 CST
6
 
   
7
 
   ��维�人��Bruce Momjian (pgman@candle.pha.pa.us)
8
 
   ���维�人��Daojing.Zhou�doudou586@gmail.com�
9
 
   
10
 
   ��档������以�
11
 
   http://www.postgresql.org/files/documentation/faqs/FAQ.html���
12
 
   
13
 
   ���系�平��������http://www.postgresql.org/docs/faq/����
14
 
   ��
15
 
     _________________________________________________________________
16
 
   
17
 
常���
18
 
 
19
 
   1.1)PostgreSQL ����该�����
20
 
   1.2)����管�PostgreSQL �
21
 
   1.3)PostgreSQL�������
22
 
   1.4)PostgreSQL�以�������系�平���
23
 
   1.5)�������PostgreSQL�
24
 
   1.6)����PostgreSQL ����
25
 
   1.7)�������对PostgreSQL ����
26
 
   1.8)����交�个BUG���
27
 
   1.9)����解已�� BUG ��缺����
28
 
   1.10)��������档����
29
 
   1.11)��该�� ���  SQL �
30
 
   1.12)���交补���� ������
31
 
   1.13)PostgreSQL ������系��起����
32
 
   1.14)PostgreSQL �以�����个�家��������
33
 
   
34
 
��客�端��
35
 
 
36
 
   2.1)�们�以������PostgreSQL �交��
37
 
   2.2)���工��以�PostgreSQL �� Web 页��
38
 
   2.3)PostgreSQL ���形������
39
 
   
40
 
系�管���
41
 
 
42
 
   3.1)��� ����PostgreSQL �� /usr/local/pgsql 以�����
43
 
   3.2)���������������
44
 
   3.3)��� ���������以���好����
45
 
   3.4)PostgreSQL ��以����� �������
46
 
   3.5)为�������������Sorry, too many clients� ���
47
 
   3.6)PostgreSQL��级������容�
48
 
   3.7)(使�PostgreSQL)���使���计��硬件 �
49
 
   
50
 
����
51
 
 
52
 
   4.1) ������个�询���头� ����������
53
 
   4.2)
54
 
   ����表�索�����以�����������psql�����询�令并��
55
 
   ���们�
56
 
   4.3) �����个�段���类��
57
 
   4.4) ��记���个表��个�����大������
58
 
   4.5) ���个������件����������空��
59
 
   4.6) 为�����询���为�����询没���索��
60
 
   4.7) ��������询������ ��估�����询��
61
 
   4.8) ��� ����表达��索�大��� ���
62
 
   ��表达������ ���索���大��� ����
63
 
   4.9) ��个�询����� ����个�段��为
64
 
   NULL�������确����论��段���NULL��
65
 
   4.10) ���符类���������
66
 
   4.11.1) ��� ��建�个������������段�
67
 
   4.11.2) ������个���������
68
 
   4.11.3) ��使� currval() �导�������������
69
 
   4.11.4) 为�������常����������为�������段���中
70
 
   ������
71
 
   4.12) ��� OID���� CTID �
72
 
   4.13) 为������误信��ERROR: Memory exhausted in
73
 
   AllocSetAlloc()��
74
 
   4.14) ����������� PostgreSQL ����
75
 
   4.15) ����建�个缺���������段�
76
 
   4.16) ��������outer join��询�
77
 
   4.17) �������个�����询�
78
 
   4.18) ��让������������
79
 
   4.19) 为����使�PL/PgSQL����临�表�����误信��relation
80
 
   with OID ##### does not exist��
81
 
   4.20) ��������������
82
 
   4.21) 为��询���示�表��������询��中
83
 
   ����为�大��������
84
 
     _________________________________________________________________
85
 
   
86
 
常���
87
 
 
88
 
  1.1)PostgreSQL ����该�����
89
 
  
90
 
   PostgreSQL 读� Post-Gres-Q-L������称为Postgres
91
 
   ���������人������载声��件� MP3 � �� �
92
 
   
93
 
   PostgreSQL
94
 
   ����� ��系���系������ ������系��������������
95
 
   ���代 DBMS 系��使���强���PostgreSQL
96
 
   ����费��并����代� ��以���
97
 
   
98
 
   PostgreSQL
99
 
   �����主�为�����们������并��������系����个社�
100
 
   ���项����被任������
101
 
   ��� ������请����人�常����FAQ�
102
 
   http://www.postgresql.org/files/documentation/faqs/FAQ_DEV.html
103
 
   
104
 
  1.2) ���PostgreSQL �
105
 
  
106
 
   ��� �寻�PostgreSQL���人�����中
107
 
   央�������������� �����---� 为�个���
108
 
   ����们�确��个
109
 
   � ������CVS管������工���设�主��为���管�工����
110
 
   �对PostgreSQL���� ����PostgreSQL项���任�人�
111
 
   ��� ���人�社����������� �����就�订��件�表���讨论
112
 
   ������PostgreSQL���详� ��人�常�� (Developer's FAQ)
113
 
   ��信���
114
 
   
115
 
  1.3)PostgreSQL������?
116
 
  
117
 
   PostgreSQL��������BSD�����许�������使�PostgreSQL����
118
 
   �以��PostgreSQL����代� ��以������就�� ��� 软件��
119
 
   �������们追���责任���就������软件��中
120
 
   须��以���声����就��们�使��BSD��声��容�
121
 
   
122
 
   PostgreSQL���管�系�
123
 
   
124
 
   �����c�1996-2005�PostgreSQL ������������c�1994-1996
125
 
   � �大���
126
 
   
127
 
   �Portions copyright (c) 1996-2005,PostgreSQL Global Development Group
128
 
   Portions Copyright (c) 1994-6 Regents of the University of
129
 
   California�
130
 
   
131
 
   �许为任���使�����修�����个软件����档����任�费�
132
 
   �� 并�� 须�署� �
133
 
   ��产�������������声���段以���两段�����������
134
 
   
135
 
   �Permission to use, copy, modify, and distribute this software and
136
 
   its documentation for any purpose, without fee, and without a written
137
 
   agreement is hereby granted, provided that the above copyright notice
138
 
   and this paragraph and the following two paragraphs appear in all
139
 
   copies.�
140
 
   
141
 
   �任������ �大������ 使��
142
 
   �软件���档�导��对任���人�����
143
 
   ���������� ����伴�����������失�责任��使� �大�
144
 
   �已�建议����失����������
145
 
   
146
 
   �IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
147
 
   PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
148
 
   DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS
149
 
   SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA
150
 
   HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.�
151
 
   
152
 
   � �大��确��任�����������������������������
153
 
   ������份软件�������������� �� �大�
154
 
   �没�责任��维���������强��修�����
155
 
   
156
 
   �THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
157
 
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
158
 
   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
159
 
   PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
160
 
   CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
161
 
   UPDATES, ENHANCEMENTS, OR MODIFICATIONS.�
162
 
   
163
 
  1.4)PostgreSQL �以�������系�平���
164
 
  
165
 
   ��说��任���对 UNIX �容���系�������PostgreSQL
166
 
   ����������������确���平��
167
 
   
168
 
   PostgreSQl��以�������微软Windows-NT���系���Win2000
169
 
   SP4�WinXP � Win2003�已����������
170
 
   http://pgfoundry.org/projects/pginstaller�载���MSDOS�Windows���
171
 
   �� �Win95�Win98�WinMe�����Cygwin模�����PostgreSQL�
172
 
   
173
 
   �����个为Novell Netware 6�������
174
 
   http://forge.novell.com���为OS/2(eComStation)�������
175
 
   http://hobbes.nmsu.edu/cgi-bin/h-search?sh=1&button=Search&key=postgre
176
 
   SQL&stype=all&sort=type&dir=%2F �载�
177
 
   
178
 
  1.5) �������PostgreSQL�
179
 
  
180
 
   �������http://www.postgresql.org/ftp/�载�����FTP��
181
 
   ftp://ftp.PostgreSQL.org/pub/���载�
182
 
   
183
 
  1.6) ����PostgreSQL����
184
 
  
185
 
   PostgreSQL �������� 8.2.1 �
186
 
   
187
 
   �们计��年���个主��级����� 个����个����
188
 
   
189
 
  1.7) �������对PostgreSQL����
190
 
  
191
 
   PostgreSQL社����件�表为�大������帮��订��件�表�主
192
 
   ���
193
 
   http://www.postgresql.org/community/lists/��������� �General �
194
 
   Bug�件�表��个�好����
195
 
   
196
 
   主��IRC����FreeNode(irc.freenode.net)�#postgresql�为����
197
 
   �����以使�UNIX��irc���令� ��� irc -c '#postgresql'
198
 
   "$USER" irc.freenode.net ���使���IRC客�端����������
199
 
   ��个PostgreSQL�西����(#postgersql-es)�����
200
 
   (#postgresql-fr)��� ����EFNET����个PostgreSQL�交����
201
 
   
202
 
   �����������表��http://techdocs.postgresql.org/companies.php�
203
 
   ��
204
 
   
205
 
  1.8) ����交�个BUG���
206
 
  
207
 
   �访�
208
 
   http://www.postgresql.org/support/submitbug�填�Bug��表� ������
209
 
    ���访�ftp��ftp://ftp.PostgreSQL.org/pub/
210
 
   ���� ���PostgreSQL���补��
211
 
   
212
 
   ��使�Bug�交表� �����PostgreSQL�件�表�Bug�常��以������
213
 
   �
214
 
     * ��交�容���个Bug����Bug��� �
215
 
     * ��交�容��个已��Bug并�已�� �TODO���任��表�
216
 
     * ��交�Bug已������被修��
217
 
     * ��交�Bug已修�����补�� ������软件��
218
 
     * 请��交����详��信��
219
 
          + ��系�
220
 
          + PostgreSQL��
221
 
          + ���Bug�����
222
 
          + ��信�
223
 
          + ���踪��
224
 
     * ��交�容��个�Bug����以�工��
225
 
          + �建�个�补�并��� ���个主�������������
226
 
          + �Bug����修���被� �TODO���任��表�
227
 
       
228
 
  1.9) ����解已�� BUG ��缺����
229
 
  
230
 
   PostgreSQL ���个��� SQL:2003 �������们�TODO
231
 
   �表��解已�Bug�表��缺���������计��
232
 
   
233
 
   ���� �����请�常���以�������
234
 
     * 该��已� �TODO���任��表�
235
 
     * 该�����须��� 为�
236
 
          + ������符�SQL� ���������
237
 
          + 该����大大�� 代� �������带��好��微�足���
238
 
          + 该����������� ��
239
 
     * 该���被� �TODO���任��表�
240
 
       
241
 
   PostgreSQL�使�Bug�踪系��� 为�们����件�表中
242
 
   ����以���TODO任��表�����������工������������
243
 
   ��Bug����们�软件��������
244
 
   对影������Bug����快�被修���������������修�
245
 
   �����CVS���信���使��软件������信�中
246
 
   ���������软件���
247
 
   
248
 
  1.10) ��������档����
249
 
  
250
 
   PostgreSQL��大���档�主��详���������页����������� /doc
251
 
   ����注��为 $PGHOME/doc��
252
 
   � ��以�线��PostgreSQL���������http://www.PostgreSQL.org/d
253
 
   ocs�
254
 
   
255
 
   �两���PostgreSQL�书�线����
256
 
   http://www.PostgreSQL.org/docs/awbook.html �
257
 
   http://www.commandprompt.com/ppbook/ � ��大��PostgreSQL书���购
258
 
   买����为�������Korry Douglas�����
259
 
   http://techdocs.PostgreSQL.org/techdocs/bookreviews.php�
260
 
   ��大���PostgreSQL书����� �
261
 
   http://techdocs.PostgreSQL.org/������PostgreSQL�大����� �
262
 
   
263
 
   客�端��令���psql���以 \d
264
 
   �头��令���示��类����符�������信��使� \?
265
 
   �以�示������令�
266
 
   
267
 
   �们� web ��������档�
268
 
   
269
 
  1.11) ��该�� ���  SQL �
270
 
  
271
 
   �����述����PostgreSQL���书�������Teach Yourself SQL in
272
 
   21 Days, Second Edition��详�������
273
 
   http://members.tripod.com/er4ebus/sql/index.htm�
274
 
   �们�许����欢The Practical SQL Handbook� Bowman, Judith S.
275
 
   ���Addison-Wesley����������欢 The Complete Reference SQL,
276
 
   Groff ���McGraw-Hill�����
277
 
   
278
 
   ���������好�����们�
279
 
     * http://www.intermedia.net/support/sql/sqltut.shtm
280
 
     * http://sqlcourse.com.
281
 
     * http://www.w3schools.com/sql/default.asp
282
 
     * http://mysite.verizon.net/Graeme_Birchall/id1.html
283
 
       
284
 
  1.12)���交补���� ������
285
 
  
286
 
   详� ��人�常��� (Developer's FAQ) �
287
 
   
288
 
  1.13)PostgreSQL������系��起����
289
 
  
290
 
   �价软件�好� ������������ �����价� ��
291
 
   
292
 
   ��
293
 
          PostgreSQL ��大�������������������
294
 
          �询�触���������������������
295
 
          �们�����们没����������类��继��������并�
296
 
          ���以��������
297
 
          
298
 
   ��
299
 
          PostgreSQL��������������类似����对�������快
300
 
          �对����������� ����������们������常�
301
 
          +/- 10%���
302
 
          
303
 
   �� �
304
 
          �们�������须��� �����就����没���们������
305
 
          ��认�����缺����稳�代� ��个������个�� beta
306
 
          �����并��们������示�们�以��稳����������
307
 
          ��产使������们�信�����们�������软件�����
308
 
          
309
 
   ��
310
 
          �们��件�表���个�常大���人������以帮�解��碰�
311
 
          ��任�����们�������解��������������软
312
 
          件�并�������解����
313
 
          �����人����群��������触使PostgreSQL�������
314
 
          ����好�����������������以���������人��
315
 
          ��1.7 ���
316
 
          
317
 
   价� �
318
 
          �们对任�����费������������
319
 
          � �以�� ����� �产��� ��们�代� ������们�����
320
 
          �声��声�� BSD������容�
321
 
          
322
 
  1.14) PostgreSQL�以�����个�家�������?
323
 
  
324
 
   PostgreSQL 8.0������使���系�中
325
 
   �������������信���8.0��以����PostgreSQL��身������
326
 
   ��信��
327
 
     _________________________________________________________________
328
 
   
329
 
��客�端��
330
 
 
331
 
  2.1) �们�以������PostgreSQL�交��
332
 
  
333
 
   PostgreSQL(缺���)����C����C��������������项����
334
 
   ���载�����项����好�
335
 
   ��们�以������计�����������
336
 
   
337
 
   ����语
338
 
   ��PHP��访�PostgreSQL����Perl�TCL�Python以�����������
339
 
   http://gborg.postgresql.org����Drivers/Interfaces������
340
 
   并���Internet�容��索��
341
 
   
342
 
  2.2) ���工��以�PostgreSQL�� Web 页��
343
 
  
344
 
   �个��以���为�����������http://www.webreview.com�
345
 
   
346
 
   对� Web ���PHP ��个�好������http://www.php.net/�
347
 
   
348
 
   对����任����人�� Perl ��� 使�CGI.pm�DBD::Pg � mod_perl �
349
 
   
350
 
  2.3)PostgreSQL���形������
351
 
  
352
 
   ����������人���������PostgreSQL�GUI�形工�软件��
353
 
   PostgreSQL社��档��个详���表�
354
 
     _________________________________________________________________
355
 
   
356
 
系�管���
357
 
 
358
 
  3.1)��� ���PostgreSQL�� /usr/local/pgsql 以�����
359
 
  
360
 
   ��� configure �� � --prefix �项�
361
 
   
362
 
  3.2) ���������������
363
 
  
364
 
   缺�����PostgreSQL��许������� unix �����TCP/IP������
365
 
   � ���修���置�件postgresql.conf中
366
 
   �listen_addresses�����置�件$PGDATA/pg_hba.conf����
367
 
   ������� host-based
368
 
   ��身份认��并����PostgreSQL������������ �PostgreSQL
369
 
   ���������
370
 
   
371
 
  3.3) ��� ��������以���好����
372
 
  
373
 
   ��个主����以��PostgreSQL����
374
 
   
375
 
   �询�����
376
 
          �主���修��询��以���好���:
377
 
          
378
 
          + �建索����表达����索��
379
 
          + 使�COPY��代��个Insert���
380
 
          + ��个SQL�����个��以���交������
381
 
          + ��个索������记��使�CLUSTER�
382
 
          + ��个�询�������记��使�LIMIT�
383
 
          + 使������询�Prepared Query)�
384
 
          + 使�ANALYZE以��精确����计�
385
 
          + ��使� VACUUM � pg_autovacuum
386
 
          + ��大�������� �索�����建索��
387
 
            
388
 
   �����置
389
 
          �置�件postgres.conf中
390
 
          ���设置��影����������表���
391
 
          管����/����������/���������置�
392
 
          �����解����http://www.varlena.com/varlena/GeneralBits/Tid
393
 
          bits/annotated_conf_e.html �
394
 
          http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html�
395
 
          
396
 
   硬件���
397
 
          计��硬件对���影����
398
 
          http://candle.pha.pa.us/main/writings/pgsql/hw_performance/inde
399
 
          x.html � http://www.powerpostgresql.com/PerfList/�
400
 
          
401
 
  3.4)PostgreSQL��以����� �������
402
 
  
403
 
   PostgreSQL ���类似 log_*
404
 
   �����置������询�������计����工�对����������
405
 
   ���
406
 
   
407
 
  3.5) 为�����������Sorry, too many
408
 
  clients�已�太����������
409
 
  
410
 
   �表示� 已达�缺�100个并����������� ����修�postgres
411
 
   ql.conf�件��max_connections��
412
 
   �� postmaster���并�����修�������postmaster�
413
 
   
414
 
  3.6)PostgreSQL��级������容 �
415
 
  
416
 
   PostgreSQL ���对�次�����级主������Bug修�工��� ��
417
 
   7.4.8 �级� 7.4.9 ��� dump � restore������
418
 
   ��������������软件������������
419
 
   
420
 
   ��PostgreSQL����该������ �使��主�����������尽快��
421
 
   ���尽管�次�级���������PostgreSQL��������设计���
422
 
   ���
423
 
   ���Bug��代� ������以��������PostgreSQL社�认为���
424
 
   ����级��������级��
425
 
   
426
 
   主����级���� 7.3 � 7.4��常�修�系�表���表���� ���
427
 
   ������������ ��们�维����件����容��� �����中
428
 
   ����导��dump�/������中
429
 
   ����导��reload�对主����级��须��
430
 
   
431
 
  3.7)(使�PostgreSQL)���使���计��硬件 �
432
 
  
433
 
   ��计��硬件大����容��人们������信��计��硬件�
434
 
   ��������������� ECC RAM�带��� �������SCSI
435
 
   �硬����质�主����便�货��� �� ����好����PostgreSQL
436
 
   � ��以���任�硬件��
437
 
   ����� ����对� �系������ 就������ 究��� �硬件��
438
 
   ������们��件�表����� 硬件�置��价��讨论�
439
 
     _________________________________________________________________
440
 
   
441
 
����
442
 
 
443
 
  4.1) ������个�询���头� ����������
444
 
  
445
 
   ��� ������ ����并�� ����询中
446
 
   ��确������ �以使�LIMIT��� ����个索�� ORDER BY中
447
 
   ��件���PostgreSQL ��就������头� �记��
448
 
   ����对�个�询��������������������询������确�
449
 
   �记��� �使�游� (cursor)�FETCH���
450
 
   
451
 
   �使�以���������记���
452
 
      SELECT  cols
453
 
      FROM tab
454
 
      ORDER BY random()
455
 
      LIMIT 1 ;
456
 
 
457
 
  4.2)
458
 
  ����表�索�����以�����������psql�����询�令并�示�们
459
 
  �
460
 
  
461
 
   �psql�使� \dt �令��示��表������解psql中
462
 
   ����令�表�使�\? ����� ��以�读 psql ��代�
463
 
   �件pgsql/src/bin/psql/describe.c����为��psql��� �令������ SQL
464
 
   �令�� ��以带 -E �项�� psql� �� ������� �psql中
465
 
   �����令��������使��SQL�询语
466
 
   ��PostgreSQL�����个�容SQL�INFORMATION SCHEMA���
467
 
   � �以�����������信��
468
 
   
469
 
   �系������以pg_ �头�系�表��述�表����
470
 
   
471
 
   使� psql -l �令�以���������
472
 
   
473
 
   ��以����
474
 
   pgsql/src/tutorial/syscat.source�件���举��������系�表�
475
 
   ��信��SELECT���
476
 
   
477
 
  4.3) �����个�段���类��
478
 
  
479
 
   �8.0������个�段���类��容���使� ALTER TABLE ALTER
480
 
   COLUMN TYPE �
481
 
   
482
 
   �以�������以�� ���
483
 
   BEGIN;
484
 
    ALTER TABLE tab ADD COLUMN new_col new_data_type;
485
 
    UPDATE tab SET new_col = CAST(old_col AS new_data_type);
486
 
    ALTER TABLE tab DROP COLUMN old_col;
487
 
    COMMIT;
488
 
 
489
 
   � ���以使�VACUUM FULL tab �令�使系���� ����� ��空��
490
 
   
491
 
  4.4) ��记���个表��个�����大������
492
 
  
493
 
   ��������
494
 
   
495
 
     �个����大尺寸�   � ���已��� 32TB �����
496
 
     �个表��大尺寸�     32 TB
497
 
     ��记���大尺寸�   1.6 TB
498
 
     �个�段��大尺寸?    1 GB
499
 
     �个表��大���      � ��
500
 
     �个表��大���       250-1600 ���类����
501
 
     �个表���大索���� � ��
502
 
   
503
 
   ������没����� �����������空������/交����约�
504
 
   ������述�������常�大��系�������大影��
505
 
   
506
 
   �表��大大� 32 TB
507
 
   �����系�对�个�件����大����大表��个 1 GB ��件�
508
 
   ��� ��件系�大����������
509
 
   
510
 
   ��缺���大���� 32K ��大��表大���大����以�� ����
511
 
   
512
 
   ��个��就���对大���2000�
513
 
   ����建索��幸����� ��索��������对��
514
 
   ����容��MD5����������索��对����������
515
 
   并����索�许对��������索�
516
 
   
517
 
  4.5) ���个������件����������空��
518
 
  
519
 
   �个 Postgres �����
520
 
   ��个���件��� ��空�����������个���件�身大�5���
521
 
   �空��
522
 
   
523
 
   ����设��个 100,000 ���件�����个����个���述�
524
 
   �设��串�平��度为20������件� � 2.8 MB��
525
 
   ������PostgreSQL����件大约� 6.4 MB:
526
 
     28 ��: ���头�大约��
527
 
     24 ��: �个����段��个����段
528
 
   +  4 ��: 页���������
529
 
   ----------------------------------------
530
 
     56 ����
531
 
 
532
 
   PostgreSQL ��页�大�� 8192 �� (8 KB)���
533
 
 
534
 
   8192 ���页
535
 
   -------------------   =  146 �/��页������
536
 
     56 ����
537
 
 
538
 
   100000 ���
539
 
   --------------------  =  685 ��页������
540
 
      146 �/��页
541
 
 
542
 
   685 ��页 * 8192 ��/页  = 5,611,520 ���5.6 MB�
543
 
 
544
 
   索���������������确���被索������ �
545
 
   ��们����大�
546
 
   
547
 
   空�NULL�������� �� ����空��
548
 
   
549
 
  4.6) 为�����询���为�����询没���索��
550
 
  
551
 
   并��个�询����使�索�����表�大����个����并��
552
 
   询����表������记������索��
553
 
   ��� 为索����起�������������读�表�顺�������
554
 
   
555
 
   为���
556
 
   ��使�索��PostgreSQL�须����表��计�����计��以使�
557
 
   � VACUUM ANALYZE�� ANALYZE ��� 使��计�������表中
558
 
   �����就���好�������索��
559
 
   �计�对确������顺������������表��容����������
560
 
   ��计�������
561
 
   
562
 
   索��常��� ORDER BY
563
 
   ������对�个大表��次顺������次���常�索����快��
564
 
   ����� LIMIT � ORDER BY
565
 
   ����起使�����常��使�索��� 为�����表中
566
 
   �����记��
567
 
   
568
 
   ��� 确信PostgreSQL����使�顺������确��� �以使�SET
569
 
   enable_seqscan TO 'off'�令���顺����
570
 
   ���次���询�� 就�以��使��个索�����确��快���
571
 
   
572
 
   �使���符����� LIKE � ~ ��索����������使��
573
 
     * �符串������须����符串��就�说�
574
 
          + LIKE 模���以 % �头�
575
 
          + ~ ���表达��模��须以 ^ �头�
576
 
     * �符串��以���个�符�模�类�头��� [a-e]�
577
 
     * 大��� ������ ILIKE � ~* ��使�索����以� 4.8
578
 
       ��述�表达�索��
579
 
     * �� initdb ��须��缺����设置 C
580
 
       locale�� 为系��������C locale�����个�大�符����
581
 
       �������� �以�建�个���text_pattern_ops索����LIKE
582
 
       �索��
583
 
       
584
 
   �8.0�����中
585
 
   �����询���类��索����类�������索��常��被����
586
 
   ���对int2,int8�����索��
587
 
   
588
 
  4.7) ��������询������ ��估�����询�
589
 
  
590
 
   �� EXPLAIN ��页�
591
 
   
592
 
  4.8) ��� ����表达��索�大��� ���
593
 
  ��表达������ ���索���大��� ����
594
 
  
595
 
   ��符 ~ ����表达����� ~* ��大��� ���
596
 
   ��表达����大��� �� LIKE ���为 ILIKE�
597
 
   
598
 
   大��� �������常���
599
 
    SELECT *
600
 
    FROM tab
601
 
    WHERE lower(col) = 'abc';
602
 
 
603
 
   �� ����使�� ��索�����以�建�个������使��表达��
604
 
   ���:
605
 
    CREATE INDEX tabindex ON tab (lower(col));
606
 
 
607
 
   ���述索���建�� �UNIQUE约����索��段�身�容�以�
608
 
   �大������容�����UNIQUE约������容�����大��������
609
 
   �� �����为������������以使�CHECK约��件��触����
610
 
   �������
611
 
   
612
 
  4.9) ��个�询����� ����个�段��为 NULL �������确����论��
613
 
  段��� NULL ��
614
 
  
615
 
   � IS NULL � IS NOT NULL ���个�段��������
616
 
   SELECT *
617
 
   FROM tab
618
 
   WHERE col IS NULL;
619
 
 
620
 
   为��对� NULL�段����� ORDER BY �件�使� IS NULL� IS NOT
621
 
   NULL 修饰符��件为� true ���件为�false ����������
622
 
   就��� NULL �记�����������
623
 
   SELECT *
624
 
   FROM tab
625
 
   ORDER BY (col IS NOT NULL)
626
 
 
627
 
  4.10) ���符类���������
628
 
  
629
 
   类� ���称 说�
630
 
   VARCHAR(n) varchar ����大�度����
631
 
   符串��足���度����补�
632
 
   CHAR(n) bpchar ���符串������足���度��以空� �补�
633
 
   TEXT text 没��������������大�度���
634
 
   BYTEA bytea �������使�NULL�符���许��
635
 
   "char" char �个�符
636
 
   
637
 
   �系�表�����误信��� ������称�
638
 
   
639
 
   ��������类��"varlena"����类���就�说��头��个�
640
 
   ���度��������� ����� ��空��声��大������
641
 
   ����类���������以被�缩���� �
642
 
   ���空�����������
643
 
   
644
 
   VARCHAR(n) �������大�度����符串��好�� TEXT ����
645
 
   ��大�达 1G左��������度��符串�
646
 
   
647
 
   CHAR(n) �������度����符串� CHAR(n)�� �������
648
 
   段�度以空� �补足��足��段�容�� � VARCHAR(n) ��
649
 
   ��������容� BYTEA ����������尤���� NULL �
650
 
   ������类���差������
651
 
   
652
 
  4.11.1) ��� ��建�个�����������段�
653
 
  
654
 
   PostgreSQL �� SERIAL ��类����
655
 
   段��为SERIAL������建�个���������
656
 
   CREATE TABLE person (
657
 
      id   SERIAL,
658
 
      name TEXT
659
 
   );
660
 
 
661
 
   ���转�为以�SQL���
662
 
   CREATE SEQUENCE person_id_seq;
663
 
   CREATE TABLE person (
664
 
      id   INT4 NOT NULL DEFAULT nextval('person_id_seq'),
665
 
      name TEXT
666
 
   );
667
 
 
668
 
   �� create_sequence ��页������������信��
669
 
   
670
 
  4.11.2) ������个���������
671
 
  
672
 
   �������������� nextval() ���对象��索���个 SERIAL
673
 
   ��������精确����使� 4.11.1 ���表���伪� �� ��述�
674
 
   new_id = execute("SELECT nextval('person_id_seq')");
675
 
   execute("INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal')");
676
 
 
677
 
   �� �������询�使���� new_id ���������为�� person
678
 
   表����� 注����建� SEQUENCE 对象��称���
679
 
   <table>_<serialcolumn>_seq� �� table � serialcolumn
680
 
   ���� �表��称�� � SERIAL �段��称�
681
 
   
682
 
   类似��� SERIAL 对象缺����� �以��� currval() �索����
683
 
   SERIAL �����
684
 
   execute("INSERT INTO person (name) VALUES ('Blaise Pascal')");
685
 
   new_id = execute("SELECT currval('person_id_seq')");
686
 
 
687
 
  4.11.3) ��使� currval() �导�������������
688
 
  
689
 
   ���currval() ����� �次��������������������
690
 
   
691
 
  4.11.4) 为�������常����������为�������段��������
692
 
  ��
693
 
  
694
 
   为���并���������������
695
 
   ��������并�������������� �就�导��常中
696
 
   ���������������
697
 
   
698
 
  4.12) ��� OID ���� CTID �
699
 
  
700
 
   PostgreSQL
701
 
   ��建����记������个���OID�����建表�使�WITHOUT
702
 
   OIDS�项� OID�建�������个4�������� OID
703
 
   ���PostgreSQL���������� �������40亿��溢�� OID�
704
 
   ��������PostgreSQL �����系�表�使� OID �表��建��系�
705
 
   
706
 
   ������表���好�使�SERIAl�代�OID
707
 
   � 为SERIAL������个表中
708
 
   �������就�以���� ��溢�����就�常���
709
 
   SERIAL8�����8��������
710
 
   
711
 
   CTID ��� �带��������������移�������� CTID
712
 
   �记�被����载������索���使��们������
713
 
   
714
 
  4.13) 为������误信��ERROR: Memory exhausted in AllocSetAlloc()��
715
 
  
716
 
   �����系�������������� �对���������������
717
 
   postmaster ��������令�
718
 
   ulimit -d 262144
719
 
   limit datasize 256m
720
 
 
721
 
   ���� ��
722
 
   shell����令�������������� �����段��设�����
723
 
   � ��许�让�询������令��������以�������令�����
724
 
   �������
725
 
   ��� ����SQL客�端�� 为�����太����������请���
726
 
   客�端�����述�令�
727
 
   
728
 
  4.14) �����������PostgreSQL����
729
 
  
730
 
   � psql ���� SELECT version();�令�
731
 
   
732
 
  4.15) ����建�个缺���������段�
733
 
  
734
 
   使� CURRENT_TIMESTAMP�
735
 
   CREATE TABLE test (x int, modtime TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
736
 
 
737
 
  4.16) ��� ��� outer join ������
738
 
  
739
 
   PostgreSQL ��� �� SQL �����������两个���
740
 
   SELECT *
741
 
   FROM t1 LEFT OUTER JOIN t2 ON (t1.col = t2.col);
742
 
 
743
 
   ��
744
 
   SELECT *
745
 
   FROM t1 LEFT OUTER JOIN t2 USING (col);
746
 
 
747
 
   �两个�价��询� t1.col � t2.col �����并��� t1 中
748
 
   ����������� t2 �没������� �[�]���RIGHT OUTER
749
 
   JOIN���� t2 ������� ������FULL OUTER JOIN���� t1 � t2
750
 
   ������� ��� OUTER �左[�]����[�]�����[�]��中
751
 
   ���������被称为����INNER JOIN��
752
 
   
753
 
  4.17) ��使����个�����询�
754
 
  
755
 
   没����询������������
756
 
   � 为PostgreSQL�� 载�������系����系�表��� �
757
 
   �跨�����询���������
758
 
   
759
 
   �� ��模�contrib/dblink�许��������跨��询�������以
760
 
   ��������������询���客�端�并���
761
 
   
762
 
  4.18) ��让������������
763
 
  
764
 
   ��������记�������容�使���详����
765
 
   http://techdocs.postgresql.org/guides/SetReturningFunctions
766
 
   
767
 
  4.19) 为����使�PL/PgSQL����临�表�����误信��relation with
768
 
  OID ##### does not exist��
769
 
  
770
 
   PL/PgSQL���������容���带���个�好�������个
771
 
   PL/PgSQL
772
 
   ��访���个临�表���该表被� �并�建����次��该���
773
 
   �失败� � 为������容������临�表�解������ PL/PgSQL
774
 
   ��EXECUTE
775
 
   对临�表��访���� �����询������被��解��
776
 
   
777
 
  4.20) ��������������
778
 
  
779
 
   �������个����好� ���������������缺��
780
 
   
781
 
   主/�������许�个主�����读/���请���个���������
782
 
   ��/SELECT�询��请� �������费�主/�PostgreSQL�����
783
 
   Slony-I �
784
 
   
785
 
   �个主���������许�读/���请������计����������
786
 
   ���������������
787
 
   ���带��严�����失�Pgcluster������� 中
788
 
   �好������以�费�载�
789
 
   
790
 
   ��������费���硬件�����������述����模��
791
 
   
792
 
  4.21) 为��询���示�表��������询�������为�大��������
793
 
  
794
 
   �常���� ���建表�对表�����使���������使��������
795
 
   ������称为� �符������� 大����
796
 
   ����� ��询�表������使�������工�软件��pgAdmin��
797
 
   ���建表��令������个� �符�� ���� � �
798
 
   ��为�� �符����� �该�
799
 
     * ��建表����� �符使�����起��
800
 
     * �� �符��使������
801
 
     * �为��已���� �符�����询�使������ �符�起��