At 10:28 AM -0700 5/4/01, Shankar Unni wrote:
>Paul DuBois writes:
>
> > > At 8:21 PM +0200 5/3/01, stefan mojschewitsch wrote:
>> >
>> >using DEFAULT USER(), would be nice, but only constants are allowed.
>> >to prevent inserting rows without iuser, i like to have this field
>> >with NOT NULL restriction and default value NULL.
>
> > That's a contradiction, isn't it?
>
>No, it's not.
>
>It's an accepted idiom for declaring a *mandatory* column (I.e. one
>that *has* to be specified in an insert). In fact, Or*cle (hiss) is
>good enough to leave the default on the column as NULL if you don't
>put an explicit default (and doesn't try to get too smart with
>creating "reasonable" defaults), so if you declare a column as NOT
>NULL and don't specify a default, it becomes mandatory to specify a
>value for the column in INSERT statements.
>
>This is good programming practice, to document mandatory columns for
>which there is *no reasonable default* (e.g. a U.S. bank account's
>"associated taxpayer number" (SSN), to make a simplistic example -
>it's not a primary key, but it's mandatory by law, and there's no
>reasonable default for it - certainly not '').
>
>--
>Shankar Unni
In that case, this section of the MySQL manual may be of interest:
@cindex default values, suppression
@cindex suppression, default values
@item
You can configure @strong{MySQL} not to use @code{DEFAULT} column values for
non-@code{NULL} columns (that is, columns that are not allowed to be
@code{NULL}). This causes @code{INSERT} statements to generate an error
unless you explicitly specify values for all columns that require a
non-@code{NULL} value. To suppress use of default values, run
@code{configure} like this:
@tindex CXXFLAGS environment variable
@tindex environment variable, CXXFLAGS
@example
shell> CXXFLAGS=-DDONT_USE_DEFAULT_FIELDS ./configure
@end example
--
Paul DuBois, [EMAIL PROTECTED]
---------------------------------------------------------------------
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 <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php