From: Nagib Abi Fadel <nagib.abi-fadel@usj.edu.lb>
To: generalpost <pgsql-general@postgresql.org>
To: developPost <pgsql-hackers@postgresql.org>
Subject: Should we consider empty fields as NULL values when dealing with string columns ?
Date: Thu, 11 Dec 2003 16:36:56 +0200
Message-ID: <001401c3bff4$49abd7f0$f664a8c0@nagib> (raw)
HI,
let's say we have the following table :
# CREATE TABLE tempo (col1 varchar(3) not null);
CREATE TABLE
# insert INTO tempo VALUES ('');
INSERT 11420541 1
the insert command works.
The issue is that since the column col1 is defined as character with not null attribute,
shouldn't we deny such inserts (i mean inserting empty fields)???
(PS: i am using postresql 7.3.2)
When using script languages (like PHP) if by mistake the variable is not defined such insert is possible (let's say we have a variable $col1_value and after a long day of work we make a mistake and write it $col_value).
This "problem" is solved by adding the constraint:
ALTER TABLE tempo add constraint col1_check check(col1!='');
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: nagib.abi-fadel@usj.edu.lb, pgsql-general@postgresql.org
Subject: Re: Should we consider empty fields as NULL values when dealing with string columns ?
In-Reply-To: <001401c3bff4$49abd7f0$f664a8c0@nagib>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox