Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Software Development Software Development
Search Search
Search for:
Tech Support Guy > > >

Solved: MySQL question


(!)

gurutech's Avatar
Computer Specs
Member with 2,918 posts.
THREAD STARTER
 
Join Date: Apr 2004
Location: Central NJ
Experience: Seasoned Professional
09-May-2012, 10:15 PM #1
Solved: MySQL question
If I add some field names to a MySQL database, and configure it to NOT allow "null" values, and set the default value to something, will the database automatically assign that value to the field, or do I have to figure out a way to manually enter the value in all existing records, with new records automatically being assigned the new value?

Thanks!
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 610 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
10-May-2012, 04:37 AM #2
If you mean "add some field names to a MySQL table", then the answer is the default values will be set for all new and existing records. The default value is set when the record, or field, is created, so adding fields will set the values in your current data and any subsequently created ones.

Danny
gurutech's Avatar
Computer Specs
Member with 2,918 posts.
THREAD STARTER
 
Join Date: Apr 2004
Location: Central NJ
Experience: Seasoned Professional
10-May-2012, 07:26 PM #3
Yes, I meant a table... sorry about that... So if I have 50 records, then add a field into the table and set default values for that field, each time one of the existing records is accessed, the database will update any "blank" fields with the default value, or does it do it automatically when you save the database after adding the field?
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 610 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
11-May-2012, 04:42 AM #4
"Default" is the value placed in a field unless an alternate is specified, so when a new field is created on an existing table it will take that default value, as it is not possible to specify an alternative. The data is set when the field is created. It won't add "blank" / empty / NULL data for the field, unless of course that is the default value set when you created it.

Danny
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑