Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5eced96

Browse files
committed
Update FAQ.
1 parent cfe26c0 commit 5eced96

File tree

2 files changed

+1190
-1126
lines changed

2 files changed

+1190
-1126
lines changed

doc/FAQ

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -214,31 +214,29 @@
214214
available for discussion of matters pertaining to PostgreSQL. To
215215
subscribe, send mail with the following lines in the body (not the
216216
subject line)
217-
subscribe
218-
end
217+
subscribe
218+
end
219219

220220
to pgsql-general-request@PostgreSQL.org.
221221

222222
There is also a digest list available. To subscribe to this list, send
223223
email to: pgsql-general-digest-request@PostgreSQL.org with a body of:
224-
subscribe
225-
end
224+
subscribe
225+
end
226226

227227
Digests are sent out to members of this list whenever the main list
228228
has received around 30k of messages.
229229

230230
The bugs mailing list is available. To subscribe to this list, send
231231
email to pgsql-bugs-request@PostgreSQL.org with a body of:
232-
233-
subscribe
234-
end
232+
subscribe
233+
end
235234

236235
There is also a developers discussion mailing list available. To
237236
subscribe to this list, send email to
238237
pgsql-hackers-request@PostgreSQL.org with a body of:
239-
240-
subscribe
241-
end
238+
subscribe
239+
end
242240

243241
Additional mailing lists and information about PostgreSQL can be found
244242
via the PostgreSQL WWW home page at:
@@ -284,7 +282,7 @@
284282
http://ourworld.compuserve.com/homepages/graeme_birchall/HTM_COOK.HTM.
285283

286284
Another one is "Teach Yourself SQL in 21 Days, Second Edition" at
287-
http://members.tripod.com/er4ebus/sql/index.htm
285+
http://members.tripod.com/er4ebus/sql/index.htm
288286

289287
Many of our users like The Practical SQL Handbook, Bowman, Judith S.,
290288
et al., Addison-Wesley. Others like The Complete Reference SQL, Groff
@@ -558,8 +556,8 @@
558556
Both postmaster and postgres have several debug options available.
559557
First, whenever you start the postmaster, make sure you send the
560558
standard output and error to a log file, like:
561-
cd /usr/local/pgsql
562-
./bin/postmaster >server.log 2>&1 &
559+
cd /usr/local/pgsql
560+
./bin/postmaster >server.log 2>&1 &
563561

564562
This will put a server.log file in the top-level PostgreSQL directory.
565563
This file contains useful information about problems or errors
@@ -668,19 +666,19 @@
668666
4.5) How do you remove a column from a table?
669667

670668
We do not support ALTER TABLE DROP COLUMN, but do this:
671-
SELECT ... -- select all columns but the one you want to remove
672-
INTO TABLE new_table
673-
FROM old_table;
674-
DROP TABLE old_table;
675-
ALTER TABLE new_table RENAME TO old_table;
669+
SELECT ... -- select all columns but the one you want to remove
670+
INTO TABLE new_table
671+
FROM old_table;
672+
DROP TABLE old_table;
673+
ALTER TABLE new_table RENAME TO old_table;
676674

677675
4.6) What is the maximum size for a row, table, database?
678676

679677
These are the limits:
680678
Maximum size for a database? unlimited (60GB databases exist)
681679
Maximum size for a table? unlimited on all operating systems
682680
Maximum size for a row? 8k, configurable to 32k
683-
Maximum number of rows in a table? unlimited
681+
Maximum number of rows in a table? unlimited
684682
Maximum number of columns in a table? unlimited
685683
Maximum number of indexes on a table? unlimited
686684

@@ -798,7 +796,7 @@ Maximum number of indexes on a table? unlimited
798796
case-insensitive regular expression matching. There is no
799797
case-insensitive variant of the LIKE operator, but you can get the
800798
effect of case-insensitive LIKE with this:
801-
WHERE lower(textfield) LIKE lower(pattern)
799+
WHERE lower(textfield) LIKE lower(pattern)
802800

803801
4.14) In a query, how do I detect if a field is NULL?
804802

@@ -818,27 +816,27 @@ BYTEA bytea variable-length byte array (null-safe)
818816
some error messages.
819817

820818
The last four types above are "varlena" types (i.e., the first four
821-
bytes on disk are the length, followed by the data). Thus the actual
822-
space used is slightly greater than the declared size. However, these
819+
bytes on disk are the length, followed by the data). Thus the actual
820+
space used is slightly greater than the declared size. However, these
823821
data types are also subject to compression or being stored out-of-line
824822
by TOAST, so the space on disk might also be less than expected.
825823

826824
4.16.1) How do I create a serial/auto-incrementing field?
827825

828826
PostgreSQL supports a SERIAL data type. It auto-creates a sequence and
829827
index on the column. For example, this:
830-
CREATE TABLE person (
831-
id SERIAL,
832-
name TEXT
833-
);
828+
CREATE TABLE person (
829+
id SERIAL,
830+
name TEXT
831+
);
834832

835833
is automatically translated into this:
836-
CREATE SEQUENCE person_id_seq;
837-
CREATE TABLE person (
838-
id INT4 NOT NULL DEFAULT nextval('person_id_seq'),
839-
name TEXT
840-
);
841-
CREATE UNIQUE INDEX person_id_key ON person ( id );
834+
CREATE SEQUENCE person_id_seq;
835+
CREATE TABLE person (
836+
id INT4 NOT NULL DEFAULT nextval('person_id_seq'),
837+
name TEXT
838+
);
839+
CREATE UNIQUE INDEX person_id_key ON person ( id );
842840

843841
See the create_sequence manual page for more information about
844842
sequences. You can also use each row's OID field as a unique value.
@@ -853,8 +851,8 @@ BYTEA bytea variable-length byte array (null-safe)
853851
object with the nextval() function before inserting and then insert it
854852
explicitly. Using the example table in 4.16.1, that might look like
855853
this:
856-
$newSerialID = nextval('person_id_seq');
857-
INSERT INTO person (id, name) VALUES ($newSerialID, 'Blaise Pascal');
854+
$newSerialID = nextval('person_id_seq');
855+
INSERT INTO person (id, name) VALUES ($newSerialID, 'Blaise Pascal');
858856

859857
You would then also have the new value stored in $newSerialID for use
860858
in other queries (e.g., as a foreign key to the person table). Note
@@ -864,8 +862,8 @@ BYTEA bytea variable-length byte array (null-safe)
864862

865863
Alternatively, you could retrieve the assigned SERIAL value with the
866864
currval() function after it was inserted by default, e.g.,
867-
INSERT INTO person (name) VALUES ('Blaise Pascal');
868-
$newID = currval('person_id_seq');
865+
INSERT INTO person (name) VALUES ('Blaise Pascal');
866+
$newID = currval('person_id_seq');
869867

870868
Finally, you could use the OID returned from the INSERT statement to
871869
look up the default value, though this is probably the least portable
@@ -933,8 +931,8 @@ BYTEA bytea variable-length byte array (null-safe)
933931
It is possible you have run out of virtual memory on your system, or
934932
your kernel has a low limit for certain resources. Try this before
935933
starting the postmaster:
936-
ulimit -d 65536
937-
limit datasize 64m
934+
ulimit -d 65536
935+
limit datasize 64m
938936

939937
Depending on your shell, only one of these may succeed, but it will
940938
set your process data segment limit much higher and perhaps allow the
@@ -964,21 +962,21 @@ BYTEA bytea variable-length byte array (null-safe)
964962
4.22) How do I create a column that will default to the current time?
965963

966964
Use now():
967-
CREATE TABLE test (x int, modtime timestamp DEFAULT now() );
965+
CREATE TABLE test (x int, modtime timestamp DEFAULT now() );
968966

969967
4.23) Why are my subqueries using IN so slow?
970968

971969
Currently, we join subqueries to outer queries by sequentially
972970
scanning the result of the subquery for each row of the outer query. A
973971
workaround is to replace IN with EXISTS:
974-
SELECT *
975-
FROM tab
976-
WHERE col1 IN (SELECT col2 FROM TAB2)
972+
SELECT *
973+
FROM tab
974+
WHERE col1 IN (SELECT col2 FROM TAB2)
977975

978976
to:
979-
SELECT *
980-
FROM tab
981-
WHERE EXISTS (SELECT col2 FROM TAB2 WHERE col1 = col2)
977+
SELECT *
978+
FROM tab
979+
WHERE EXISTS (SELECT col2 FROM TAB2 WHERE col1 = col2)
982980

983981
We hope to fix this limitation in a future release.
984982

@@ -988,14 +986,14 @@ BYTEA bytea variable-length byte array (null-safe)
988986
can be simulated using UNION and NOT IN. For example, when joining
989987
tab1 and tab2, the following query does an outer join of the two
990988
tables:
991-
SELECT tab1.col1, tab2.col2
992-
FROM tab1, tab2
993-
WHERE tab1.col1 = tab2.col1
994-
UNION ALL
995-
SELECT tab1.col1, NULL
996-
FROM tab1
997-
WHERE tab1.col1 NOT IN (SELECT tab2.col1 FROM tab2)
998-
ORDER BY tab1.col1
989+
SELECT tab1.col1, tab2.col2
990+
FROM tab1, tab2
991+
WHERE tab1.col1 = tab2.col1
992+
UNION ALL
993+
SELECT tab1.col1, NULL
994+
FROM tab1
995+
WHERE tab1.col1 NOT IN (SELECT tab2.col1 FROM tab2)
996+
ORDER BY tab1.col1
999997
_________________________________________________________________
1000998

1001999
Extending PostgreSQL

0 commit comments

Comments
 (0)