X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EAF55529C0 for ; Fri, 8 Jul 2005 13:32:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94469-08 for ; Fri, 8 Jul 2005 16:32:22 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 0379A5286A for ; Fri, 8 Jul 2005 13:32:20 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j68GWFF0099347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 8 Jul 2005 10:32:18 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j68GWFxb081905; Fri, 8 Jul 2005 10:32:15 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j68GWFI9081904; Fri, 8 Jul 2005 10:32:15 -0600 (MDT) (envelope-from mfuhr) Date: Fri, 8 Jul 2005 10:32:15 -0600 From: Michael Fuhr To: Ying Lu Cc: pgsql-sql@postgresql.org Subject: Re: Index creation question for expression (col1 || '-' || col2) Message-ID: <20050708163215.GA81846@winnie.fuhr.org> References: <42CEA509.3090507@cs.concordia.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42CEA509.3090507@cs.concordia.ca> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/85 X-Sequence-Number: 22063 On Fri, Jul 08, 2005 at 12:08:41PM -0400, Ying Lu wrote: > > CREATE INDEX idx_t1 ON test (col1 || '-' || col2); > > May I know is it possible and how I may create index for the expression > such as "col1 || '-' || col2" for a table please? See "Indexes on Expressions" in the documentation: http://www.postgresql.org/docs/8.0/static/indexes-expressional.html "The syntax of the CREATE INDEX command normally requires writing parentheses around index expressions, as shown in the second example...." That second example is exactly what you're trying to do: CREATE INDEX people_names ON people ((first_name || ' ' || last_name)); -- Michael Fuhr http://www.fuhr.org/~mfuhr/