From d68e08d1fea8b71057849321a17f87839a2ecbd0 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 23 Dec 2009 17:41:45 +0000 Subject: Allow the index name to be omitted in CREATE INDEX, causing the system to choose an index name the same as it would do for an unnamed index constraint. (My recent changes to the index naming logic have helped to ensure that this will be a reasonable choice.) Per a suggestion from Peter. A necessary side-effect is to promote CONCURRENTLY to type_func_name_keyword status, ie, it can't be a table/column/index name anymore unless quoted. This is not all bad, since we have heard more than once of people typing CREATE INDEX CONCURRENTLY ON foo (...) and getting a normal index build of an index named "concurrently", which was not what they wanted. Now this syntax will result in a concurrent build of an index with system-chosen name; which they can rename afterwards if they want something else. --- doc/src/sgml/keywords.sgml | 4 ++-- doc/src/sgml/ref/create_index.sgml | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/keywords.sgml b/doc/src/sgml/keywords.sgml index 4e8b7d75023..deb72e79bc8 100644 --- a/doc/src/sgml/keywords.sgml +++ b/doc/src/sgml/keywords.sgml @@ -1,4 +1,4 @@ - + <acronym>SQL</acronym> Key Words @@ -921,7 +921,7 @@ CONCURRENTLY - non-reserved + reserved (can be function or type) diff --git a/doc/src/sgml/ref/create_index.sgml b/doc/src/sgml/ref/create_index.sgml index 49352accae0..1966cb9daeb 100644 --- a/doc/src/sgml/ref/create_index.sgml +++ b/doc/src/sgml/ref/create_index.sgml @@ -1,5 +1,5 @@ @@ -21,7 +21,7 @@ PostgreSQL documentation -CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] name ON table [ USING method ] +CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ name ] ON table [ USING method ] ( { column | ( expression ) } [ opclass ] [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] ) [ WITH ( storage_parameter = value [, ... ] ) ] [ TABLESPACE tablespace ] @@ -33,8 +33,8 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] nameDescription - CREATE INDEX constructs an index named name on the specified table. + CREATE INDEX constructs an index + on the specified column(s) of the specified table. Indexes are primarily used to enhance database performance (though inappropriate use can result in slower performance). @@ -132,7 +132,9 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] name The name of the index to be created. No schema name can be included here; the index is always created in the same schema as its parent - table. + table. If the name is omitted, PostgreSQL chooses a + suitable name based on the parent table's name and the indexed column + name(s). @@ -514,8 +516,10 @@ CREATE UNIQUE INDEX title_idx ON films (title); To create an index on the expression lower(title), allowing efficient case-insensitive searches: -CREATE INDEX lower_title_idx ON films ((lower(title))); +CREATE INDEX ON films ((lower(title))); + (In this example we have chosen to omit the index name, so the system + will choose a name, typically films_lower_idx.) @@ -544,7 +548,7 @@ CREATE INDEX gin_idx ON documents_table (locations) WITH (fastupdate = off); films and have the index reside in the tablespace indexspace: -CREATE INDEX code_idx ON films(code) TABLESPACE indexspace; +CREATE INDEX code_idx ON films (code) TABLESPACE indexspace; -- cgit v1.2.3