Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 4EB041336FA7 for ; Fri, 4 Feb 2011 12:38:50 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 29495-05 for ; Fri, 4 Feb 2011 16:38:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wy0-f174.google.com (mail-wy0-f174.google.com [74.125.82.174]) by mail.postgresql.org (Postfix) with ESMTP id 973371337B49 for ; Fri, 4 Feb 2011 12:38:42 -0400 (AST) Received: by wyb28 with SMTP id 28so2436775wyb.19 for ; Fri, 04 Feb 2011 08:38:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=mA7jjth6Rorc/rCgIKiCZl2K1bgpNXgURWJyU06uuRs=; b=EpTzhsAE4EI3I8EWJsKD0upU4ngRxvMzVLrXujG7HSAPBmBegG6Aqp5hGSNRYxaNyk Kd3UTWc+ZGjx3v4S/Cy4NTeg3q8qEp3hn/zrO18OtwmAk6YSudhR8ugTKo0AGVXMqKAz rtRrUn92cuhA8H4F5uwWr8wgkjRhwasKE0wi8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=YTRVyl0nhpVJfIbE2mVwYnwKpq+chHiZwuJm6HfY/J/WMZsS36/l0TxUYvhlgvOXqM WtwXslYlEZVtWnQHqkZUZl3Mjk85ze9KgOOTVzrk9KS1P4ODtvdzLDigFLVBdn0rT2ri z2I57gl1XgAJzeMs7JFs/70zTJlKmS4xYSkL8= MIME-Version: 1.0 Received: by 10.216.187.10 with SMTP id x10mr10753376wem.97.1296837520951; Fri, 04 Feb 2011 08:38:40 -0800 (PST) Received: by 10.216.18.13 with HTTP; Fri, 4 Feb 2011 08:38:40 -0800 (PST) In-Reply-To: <1296679230744-3368417.post@n5.nabble.com> References: <1296679230744-3368417.post@n5.nabble.com> Date: Fri, 4 Feb 2011 08:38:40 -0800 Message-ID: Subject: Re: How to checking the existance of constraints for a table? From: bricklen To: creationw Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7 X-Spam-Level: X-Archive-Number: 201102/19 X-Sequence-Number: 35095 On Wed, Feb 2, 2011 at 12:40 PM, creationw wrote: > > Hello, > > I have a sample table describe as follows, anyone knows how to checking t= he > existence of a constraint? > > oviddb=3D# \d myTable > > =C2=A0Column =C2=A0| =C2=A0 Type =C2=A0 | Modifiers > ---------+----------+----------- > =C2=A0orderid | smallint | not null > =C2=A0modelid | smallint | not null > > Indexes: > =C2=A0 =C2=A0"mytable_orderid_key" UNIQUE, btree (orderid) > > For example, how to know that myTable has a constraint with name > "mytable_orderid_key"? You could try checking the information_schema.table_constraints view. Eg. select * from information_schema.table_constraints where table_name=3D'myTable'