Adding Field With Data?

Hi Guys,

I have a question for you which is playing on my mind, i’m trying to add a field to a table which already has data in but i want the new fields to place data in each row for each new field that i add. So for example say my table looked like this:

FirstName, LastName, Username

Jerry, Thomas, Jtom2
Jenna, Fish, jfish4
Darren, Jackson, Dazzbo33
Chris, Hunt, Hunty93

How do i add a new field to the table which will automatically add a default value of ‘-’. So say i wanted to add a new field called EmailAddress the rows would now look like

FirstName, LastName, Username, EmailAddress

Jerry, Thomas, Jtom2, -
Jenna, Fish, jfish4, -
Darren, Jackson, Dazzbo33, -
Chris, Hunt, Hunty93, -

How do i do this please?

Thanks in advance! :slight_smile:

Ideally, you’d want to have a NULL default I’d say. If you need a hyphen when you display the data, do it then.

    EmailAddress VARCHAR(255) DEFAULT null 

Something like that. :slight_smile:

Hi Anthony,

Thanks for the reply, I know how to add a new field to a table but the problem im facing is i dont know once i have added the new field to the table how to place data in the new field for exisiting data already in the table. For example my table has over 1,000,000 records, how do i add ‘-’ into the new field i just added to the table to the exisiting records?

Sorry my mind is blank, been doing SQL 12hrs none stop now without sleep and its about time i really need to get some sleep, taking half an hour to find simple problems such as missing commas tells me i need to go to sleep. 08:33 here in Manchester (UK) so my bed is calling very soon.


In which case, my previous point still stands. Don’t use a hyphen, use NULL. If you need to display a hyphen when you render the results, do it then; not now. :slight_smile:

You’re going to be (potentially) storing a million hyphens for no benefit what so ever.

Unless of course you know why you need to store a million hyphens?