SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Proper Query Building

    Hi,

    I've been wondering, what should I use, what is more professionally correct:
    Code:
    ALTER TABLE `table_name` DROP `column_name`
    or
    Code:
    ALTER TABLE `table_name` DROP COLUMN `column_name`
    Also,
    Code:
    ALTER TABLE `table_name` ADD `column_name` VARCHAR(250)
    or
    Code:
    ALTER TABLE `table_name` ADD COLUMN `column_name` VARCHAR(250)
    All of the above cases work just fine, is there anything to be kept in mind though? Older versions of MySQL lack of support, for instance? Anyone please shed some light, thank you!

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,215
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    in both of the cases you cited, the keyword COLUMN is optional and default

    this is true not just in the mysql database product but in standard sql as well, so you'll be just fine whichever way you write it, even if you use some other database product

    but me, i would always write it, just to self-document the statement, that you aren't adding something else to the table that's not a column
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •