Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VS9NZ-0001Db-Lj for pgsql-sql@arkaria.postgresql.org; Fri, 04 Oct 2013 17:41:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VS9NZ-0006Te-0e for pgsql-sql@arkaria.postgresql.org; Fri, 04 Oct 2013 17:41:29 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VS9NX-0006TX-TM for pgsql-sql@postgresql.org; Fri, 04 Oct 2013 17:41:28 +0000 Received: from mail-ea0-x22d.google.com ([2a00:1450:4013:c01::22d]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VS9NT-0006sB-7J for pgsql-sql@postgresql.org; Fri, 04 Oct 2013 17:41:27 +0000 Received: by mail-ea0-f173.google.com with SMTP id g10so1971393eak.18 for ; Fri, 04 Oct 2013 10:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=Wd/C811dl9s1TwoYzPdqkSrAs0i57fq4WYsS0W2aafg=; b=WSsUlbBzT2Z4dRd+LQAiL1mhqyhmBYtNuu5JGU6b8ocQUYRMoQSk2pL5tXdBzz5Bfe gZuspHiKlQuQjZ3Rdf0RqppEnVUq3c4wJFX/9yoBAELh0uZX4pJ76kK7+1H57DIYPDNn wDpo/FdSg5Zb6uisEVLYtrxiW/ubbp7ozikWTSoZYE4Id8w0wJ3jQ1BkhfM1wg7O9jde WhpzYUbqylSnMBJhWKyYke7or0w8W+4h1EIosO5/W+5N24WjFYVCBwOlF/cpkxwqQx7/ x999in653YCQ3F2+PScOS7zeFlnWGU9+qfvIPyoYCOxGnaBRnDWNhNqNgnebdt7ns0b6 PK4A== X-Received: by 10.14.211.136 with SMTP id w8mr3959915eeo.80.1380908481907; Fri, 04 Oct 2013 10:41:21 -0700 (PDT) Received: from [192.168.1.42] (host82-66-dynamic.180-80-r.retail.telecomitalia.it. [80.180.66.82]) by mx.google.com with ESMTPSA id h52sm30363439eez.3.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Oct 2013 10:41:21 -0700 (PDT) Message-ID: <524EFDBD.9010204@gmail.com> Date: Fri, 04 Oct 2013 19:41:17 +0200 From: "lucazeo@gmail.com" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Unique index VS unique constraint References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 0.7 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Il 04/10/2013 18:48, JORGE MALDONADO ha scritto: > I have search for information about the difference between "unique > index" and "unique constraint" in PostgreSQL without getting to a > specific answer, so I kindly ask for an explanation that helps me > clarify such concept. 2 main differences. First is the meaning: primary key identifies a record. A unique just tells you that that value of the record, in the table is unique. If you use keys, db structure will be more intelligible (my opinion). Second one is functional: in an unique constraint you can allow NULL values and ignore them. A primary key does not allow this. > Respectfully, > Jorge Maldonado Regards, Luca. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql