1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Adding A new Field - MySQL

Discussion in 'MySQL' started by saurabhk, Dec 22, 2006.

  1. #1
    How can I add a new field (column) in an existing MySql Table ?
    Please give SQL code
    Thanks in advance
     
    saurabhk, Dec 22, 2006 IP
  2. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ALTER TABLE [I]tablename[/I] ADD [I]newfieldname[/I] [I]newfieldattributes[/I] AFTER [I]existingfield[/I]
    Code (markup):
     
    daboss, Dec 22, 2006 IP
  3. saurabhk

    saurabhk Peon

    Messages:
    149
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for quick reply, existingfield-? is it possible to add new field between existing fields?
     
    saurabhk, Dec 22, 2006 IP
  4. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #4
    sure why not? ;)

    say you want to insert the new field between existingfield1 and existingfield2, you would use existingfield1 in the sql statement:

    ALTER TABLE tablename ADD newfieldname newfieldattributes AFTER [B][COLOR="Red"]existingfield1[/COLOR][/B]
    Code (markup):
     
    daboss, Dec 22, 2006 IP
  5. saurabhk

    saurabhk Peon

    Messages:
    149
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks Again
     
    saurabhk, Dec 23, 2006 IP
  6. Seiya

    Seiya Peon

    Messages:
    4,666
    Likes Received:
    404
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Using phpmyadmin is the easiest way... but that query posted looks fine.
     
    Seiya, Dec 23, 2006 IP
  7. Aceday

    Aceday Banned

    Messages:
    711
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ya phpmyadmin is best
     
    Aceday, Dec 27, 2006 IP
  8. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    118
    #8
    Thanks for this but can i know what are the field Attributes as i m new in mysql
     
    riteshsanap, Mar 1, 2011 IP