How to add columns in an existing table in phpmyadmin

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • glady
    New Member
    • Nov 2006
    • 23

    How to add columns in an existing table in phpmyadmin

    Hi,
    How can i add(append) extra columns to a table using phpmyadmin? or through coding?
    Thanks.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    - click the db at the left side of the screen, tables are shown
    - click the table name at the left side of the screen
    - all columns are displayed at right hand side of screen
    - below the column display there is a row
    Code:
    Add  field(s)At End of Table At Beginning of Table After column_name GO
    At that line you can add a new column to the show table.

    Ronald :cool:

    Comment

    • glady
      New Member
      • Nov 2006
      • 23

      #3
      Originally posted by ronverdonk
      - click the db at the left side of the screen, tables are shown
      - click the table name at the left side of the screen
      - all columns are displayed at right hand side of screen
      - below the column display there is a row
      Code:
      Add  field(s)At End of Table At Beginning of Table After column_name GO
      At that line you can add a new column to the show table.

      Ronald :cool:
      Thanks a lot !!!!:-)

      Comment

      • glady
        New Member
        • Nov 2006
        • 23

        #4
        Originally posted by glady
        Thanks a lot !!!!:-)
        Hey ,How could i do the same using coding?

        Comment

        • guruparthi
          Banned
          New Member
          • Dec 2013
          • 1

          #5
          For add column:
          Code:
          ALTER TABLE table_name add COLUMN column_name varchar(30)
          For add column after specific filed,
          Code:
          ALTER TABLE table_name add COLUMN column_name varchar(30) AFTER column_name
          For add column at first
          Code:
          ALTER TABLE table_name add COLUMN column_name varchar(30)FIRST
          <Snip>
          Last edited by NeoPa; Jan 12 '14, 02:38 AM. Reason: Spam link removed.

          Comment

          • johndavid19
            New Member
            • Jun 2014
            • 4

            #6
            You can add column after particular field. The mysql query is
            Code:
            alter table table_name add column col_name datatype(length) after field_name
            where, you need to use "after" keyword

            Similarly, you can also add column at first of table. the query is
            Code:
            alter table table_name add column col_name first
            Here you need to use "first" keyword

            Comment

            Working...