1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: MySQL question

Discussion in 'Software Development' started by gurutech, May 9, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. gurutech

    gurutech Thread Starter

    Joined:
    Apr 23, 2004
    Messages:
    2,959
    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!
     
  2. allnodcoms

    allnodcoms

    Joined:
    Jun 30, 2007
    Messages:
    613
    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
     
  3. gurutech

    gurutech Thread Starter

    Joined:
    Apr 23, 2004
    Messages:
    2,959
    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?
     
  4. allnodcoms

    allnodcoms

    Joined:
    Jun 30, 2007
    Messages:
    613
    "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
As Seen On...

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.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1052631