From 624aa2a13bd02dd584bb0995c883b5b93b2152df Mon Sep 17 00:00:00 2001 From: Dean Rasheed Date: Thu, 21 Jul 2022 19:23:13 +0100 Subject: Make the name optional in CREATE STATISTICS. This allows users to omit the statistics name in a CREATE STATISTICS command, letting the system auto-generate a sensible, unique name, putting the statistics object in the same schema as the table. Simon Riggs, reviewed by Matthias van de Meent. Discussion: https://postgr.es/m/CANbhV-FGD2d_C3zFTfT2aRfX_TaPSgOeKES58RLZx5XzQp5NhA@mail.gmail.com --- doc/src/sgml/ref/create_statistics.sgml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/create_statistics.sgml b/doc/src/sgml/ref/create_statistics.sgml index 9a8c904c088..b847944f37d 100644 --- a/doc/src/sgml/ref/create_statistics.sgml +++ b/doc/src/sgml/ref/create_statistics.sgml @@ -21,11 +21,11 @@ PostgreSQL documentation -CREATE STATISTICS [ IF NOT EXISTS ] statistics_name +CREATE STATISTICS [ [ IF NOT EXISTS ] statistics_name ] ON ( expression ) FROM table_name -CREATE STATISTICS [ IF NOT EXISTS ] statistics_name +CREATE STATISTICS [ [ IF NOT EXISTS ] statistics_name ] [ ( statistics_kind [, ... ] ) ] ON { column_name | ( expression ) }, { column_name | ( expression ) } [, ...] FROM table_name @@ -60,8 +60,8 @@ CREATE STATISTICS [ IF NOT EXISTS ] statistics_na If a schema name is given (for example, CREATE STATISTICS myschema.mystat ...) then the statistics object is created in the specified schema. Otherwise it is created in the current schema. - The name of the statistics object must be distinct from the name of any - other statistics object in the same schema. + If given, the name of the statistics object must be distinct from the name + of any other statistics object in the same schema. @@ -78,6 +78,7 @@ CREATE STATISTICS [ IF NOT EXISTS ] statistics_na exists. A notice is issued in this case. Note that only the name of the statistics object is considered here, not the details of its definition. + Statistics name is required when IF NOT EXISTS is specified. @@ -88,6 +89,9 @@ CREATE STATISTICS [ IF NOT EXISTS ] statistics_na The name (optionally schema-qualified) of the statistics object to be created. + If the name is omitted, PostgreSQL chooses a + suitable name based on the parent table's name and the defined column + name(s) and/or expression(s). -- cgit v1.2.3