Search Postgresql Archives

Re: Checking for string data that makes sense Re: postgresql vs mysql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 22/02/07, Shashank Tripathi <shanx@xxxxxxxxx> wrote:
>  I would do a CHECK (trim(a) <> '')


TRIM() would add some processing time, so I'd include it only if there
was a chance of spaces getting added. From a puritanical point of
view, it is definitely a good idea.

To the original poster, this syntax should work in MySQL as well:

   create table mytable (mycol text not null check (mycol <> ''));

Problem is, if you created your table before MySQL 5, and now simply
want to ALTER your table (which is what I gather you wish to do, as
you already have the table) then adding the CHECK condition may not
work.

I cannot help in this case, and from the turn this thread has taken,
not many others I suppose. Why not try a MySQL experts list instead of
PostgreSQL, but be prepared to have to recreate the table in MySQL 5
with the CHECK constraint, and then importing your data in to it.

Good luck!



Sorry, I spoke too soon. MySQL does not do the constraints jig yet.

"The CHECK  clause is parsed but ignored by all storage engines."
- From http://dev.mysql.com/doc/refman/5.0/en/create-table.html

So you may want to adopt some kludges, such as updatable views:
http://arjen-lentz.livejournal.com/49881.html

If I were you, I'd just stick to error-checking in the application
layer for now, or consider slowly switching to PostgreSQL. (No plug
intended)

Shanx


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux