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

Re: [MySQL] can you have a no-default column; error if unspecified?


Bennett Haselton wrote:

> Is it possible to set a column to have no possible default value, so if you
> try to create a record that doesn't specify a value for that column, you'll
> get an error?

    Set it to NOT NULL


> For example, if I have a table where the "date" field should always be
> set.  I took out the default "NULL" value, but that just gave it a default
> value of 0000-00-00.  What I want to ensure is that it's not possible to
> create a record for which the date value hasn't been specified.

    Who's going to stop a user from entering 0000-00-00?  You'll have to create validation schemes in your code.

--
H | "Life is the art of drawing without an eraser." - John Gardner
  +--------------------------------------------------------------------
  Ashley M. Kirchner <mailto:ashley@xxxxxxxxxx>   .   303.442.6410 x130
  Director of Internet Operations / SysAdmin    .     800.441.3873 x130
  Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave, #6
  http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <mysql-thread92863@xxxxxxxxxxxxxxx>
To unsubscribe, e-mail <mysql-unsubscribe-treed=ultraviolet.org@xxxxxxxxxxxxxxx>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



This mailing list archive is a service of Copilot Consulting.