| From: | Chris <dmagick(at)gmail(dot)com> |
|---|---|
| To: | Erick Papadakis <erick(dot)papa(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: postgresql vs mysql |
| Date: | 2007-02-22 02:08:04 |
| Message-ID: | 45DCFB04.8030503@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Erick Papadakis wrote:
> So how should I make a database rule in MySQL to not allow blank
> strings. Basically to REQUIRE a value for that column, whether it is
> NULL or NADA or VOID or whatever you wish to call it. I just want to
> make sure that something, some value, is entered for a column. Would
> appreciate any thoughts or pointers.
>
> Does PostgreSQL suffer from this oddity as well? This distinction
> between an empty string and a NULL? Could you also please give me an
> example of where this would be useful from a business logic
> standpoint? Why should a NULL be different from an empty string,
> what's the big mysterious difference?
It's not an oddity.
An empty string is a KNOWN value. You know exactly what that value is -
it's an empty string.
A NULL is UNKNOWN - it doesn't have a value at all.
In postgres, to stop an empty blank string:
create table a(a text not null check (char_length(a) > 0));
though that allows a single space in..
See http://www.postgresql.org/docs/8.2/interactive/ddl-constraints.html
and
http://www.postgresql.org/docs/8.2/interactive/ddl-alter.html#AEN2302
No idea about how to do this in mysql, search their documentation.
--
Postgresql & php tutorials
http://www.designmagick.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Fuhr | 2007-02-22 02:10:57 | Re: How can you tell if a function is immutable from psql? |
| Previous Message | Rich Shepard | 2007-02-22 02:06:50 | Re: postgresql vs mysql |