When to use NULL as default value

2003-08-21 Thread Charles Kline
Hi all,

I pretty much set a fields default value to NULL if it not a required 
field in my app. Just wondering if this is the way to go since I just 
sort of guessed at this method ;)

- Charles

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Null to a value...

2002-09-08 Thread Chuck \PUP\ Payne

Hi again,

I need to change cross 600 records that have 'Null' in the field and I need
to change it a value. What is the sql statement that will let me change that
field.

Chuck Payne
Magi Design and Support


-
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




RE: Null to a value...

2002-09-08 Thread Bryant Hester

 
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Chuck,

If you need to change NULLs to a value all you need do is:

UPDATE table_name SET field_name = 'your_value' WHERE field_name IS
NULL;

HTH,
Bryant Hester

- -Original Message-
From: Chuck PUP Payne [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, September 08, 2002 2:35 PM
To: [EMAIL PROTECTED]
Subject: Null to a value...


Hi again,

I need to change cross 600 records that have 'Null' in the field and
I need to change it a value. What is the sql statement that will let
me change that field.

Chuck Payne
Magi Design and Support


- -
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

-BEGIN PGP SIGNATURE-
Version: PGPfreeware 7.0.3 for non-commercial use http://www.pgp.com

iQA/AwUBPXuqlUlWu7/HFp4nEQLU+QCfUCU6cSEmIdmU9TdXs+gSd5RaSjcAn2ri
3c5Mom7FPV/gxGUQnOwuXrqb
=tUOk
-END PGP SIGNATURE-


-
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




ENUM NOT NULL without default value

2001-09-30 Thread Corin Hartland-Swann


Hi Monty,

I've been experimenting with ENUM NOT NULL columns without a default
value. The documentation (section 6.5.3 again) states:

If no DEFAULT value is specified for a column, MySQL automatically
assigns one. If the column may take NULL as a value, the default value is
NULL. If the column is declared as NOT NULL, the default value depends on
the column type ... for ENUM, the default is the first enumeration value.

This is all fine (and seems like a reasonable assumption to make), but I
discovered that using ALTER TABLE on the column to DROP DEFAULT does
nothing - but that SET DEFAULT '' does remove it.

Would it be possible to make DROP DEFAULT set the default to '' on an
ENUM NOT NULL column?

Here's an example of what I'm talking about:

mysql CREATE TABLE test_enum (e ENUM('a','b','c') NOT NULL);
mysql DESCRIBE test_enum;
+---+---+--+-+-+---+
| Field | Type  | Null | Key | Default | Extra |
+---+---+--+-+-+---+
| e | enum('a','b','c') |  | | a   |   |
+---+---+--+-+-+---+

mysql ALTER TABLE test_enum ALTER COLUMN e DROP DEFAULT;
mysql DESCRIBE test_enum;
+---+---+--+-+-+---+
| Field | Type  | Null | Key | Default | Extra |
+---+---+--+-+-+---+
| e | enum('a','b','c') |  | | a   |   |
+---+---+--+-+-+---+

mysql ALTER TABLE test_enum ALTER COLUMN e SET DEFAULT '';
mysql DESCRIBE test_enum;
+---+---+--+-+-+---+
| Field | Type  | Null | Key | Default | Extra |
+---+---+--+-+-+---+
| e | enum('a','b','c') |  | | |   |
+---+---+--+-+-+---+

Thanks,

Corin

/+-\
| Corin Hartland-Swann   |Tel: +44 (0) 20 7491 2000|
| Commerce Internet Ltd  |Fax: +44 (0) 20 7491 2010|
| 22 Cavendish Buildings | Mobile: +44 (0) 79 5854 0027| 
| Gilbert Street | |
| Mayfair|Web: http://www.commerce.uk.net/ |
| London W1K 5HJ | E-Mail: [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




Re: ENUM NOT NULL without default value

2001-09-30 Thread Paul DuBois

At 2:43 AM +0100 10/1/01, Corin Hartland-Swann wrote:
Hi Monty,

I've been experimenting with ENUM NOT NULL columns without a default
value. The documentation (section 6.5.3 again) states:

If no DEFAULT value is specified for a column, MySQL automatically
assigns one. If the column may take NULL as a value, the default value is
NULL. If the column is declared as NOT NULL, the default value depends on
the column type ... for ENUM, the default is the first enumeration value.

This is all fine (and seems like a reasonable assumption to make), but I
discovered that using ALTER TABLE on the column to DROP DEFAULT does
nothing - but that SET DEFAULT '' does remove it.

Would it be possible to make DROP DEFAULT set the default to '' on an
ENUM NOT NULL column?

That would be incorrect.

DROP DEFAULT drops whatever default is currently assigned, and then MySQL
assigns the default value that it would otherwise automatically define.
For a NOT NULL enumeration column, that's the first enumeration value,
according to the passage you quote above.

Why introduce a change to DROP DEFAULT that makes it inconsistent
with its current behavior, particularly when you can just use
SET DEFAULT to set the default to '' if that's what you want?

Here's an example of what I'm talking about:

mysql CREATE TABLE test_enum (e ENUM('a','b','c') NOT NULL);
mysql DESCRIBE test_enum;
+---+---+--+-+-+---+
| Field | Type  | Null | Key | Default | Extra |
+---+---+--+-+-+---+
| e | enum('a','b','c') |  | | a   |   |
+---+---+--+-+-+---+

mysql ALTER TABLE test_enum ALTER COLUMN e DROP DEFAULT;
mysql DESCRIBE test_enum;
+---+---+--+-+-+---+
| Field | Type  | Null | Key | Default | Extra |
+---+---+--+-+-+---+
| e | enum('a','b','c') |  | | a   |   |
+---+---+--+-+-+---+

mysql ALTER TABLE test_enum ALTER COLUMN e SET DEFAULT '';
mysql DESCRIBE test_enum;
+---+---+--+-+-+---+
| Field | Type  | Null | Key | Default | Extra |
+---+---+--+-+-+---+
| e | enum('a','b','c') |  | | |   |
+---+---+--+-+-+---+

Thanks,

Corin

/+-\
| Corin Hartland-Swann   |Tel: +44 (0) 20 7491 2000|
| Commerce Internet Ltd  |Fax: +44 (0) 20 7491 2010|
| 22 Cavendish Buildings | Mobile: +44 (0) 79 5854 0027|
| Gilbert Street | |
| Mayfair|Web: http://www.commerce.uk.net/ |
| London W1K 5HJ | E-Mail: [EMAIL PROTECTED]|
\+-/





-- 
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