Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 90C465E060A for ; Tue, 31 Jan 2012 04:20:56 -0400 (AST) Received: from rs133.luxsci.com ([72.32.115.26]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rs8xU-0001gy-66 for pgsql-admin@postgresql.org; Tue, 31 Jan 2012 08:20:56 +0000 Received: from GNANAM (NSG-Static-233.156.72.182.airtel.in [182.72.156.233] (may be forged)) (authenticated bits=0) by rs133.luxsci.com (8.13.8/8.13.8) with ESMTP id q0V8K7Cn006118; Tue, 31 Jan 2012 02:20:41 -0600 Reply-To: From: "Gnanakumar" To: Subject: Is it possible to create a CHECK constraint for my use case? Date: Tue, 31 Jan 2012 13:41:00 +0530 Organization: Zoniac Software Private Limited Message-ID: <006c01ccdfef$e0396f60$a0ac4e20$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Aczf791HPetOeryqQL2y41+IyRJfGw== Content-Language: en-us X-Lux-Comment: Message q0V8K7Cn006118 sent by user #22393 X-Pg-Spam-Score: 0.8 (/) X-Archive-Number: 201201/146 X-Sequence-Number: 39058 Hi, Our Production server is running PostgreSQL v8.2.22 on CentOS5.2. We want to enable a specific CHECK constraint for our application table as explained below: There are 2 columns in the table: "managertype" numeric(1) and "managerid" numeric(10). "managertype" accepts only 2 valid values, either '1' or '2'. managertype | managerid --------------------------------- 1 | null values NOT allowed 2 | null values allowed --------------------------------- We want to enable a CHECK constraint based on 2 columns data in the table in such a way that if "managertype" is 1, then null values are not allowed in "managerid" column. In other words, I want to create a CHECK constraint something like this: IF (managertype = 1) THEN managerid IS NOT NULL. Is it possible to create a CHECK constraint for my use case explained above? Regards, Gnanam