Announcement

Collapse
No announcement yet.

ALTER TABLE syntax

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ALTER TABLE syntax

    I need to remove a column in a sql 6.5 table. According to the syntax I just

    ALTER TABLE clients DROP COLUMN saledate

    But this apparently doesn't work. Nudge me to the correct syntax please someone!

    #2
    That seems to be the right syntax in sql server 2000 and oracle at least, I've never used 6.5. What error message are you getting?

    Comment


      #3
      Incorrect syntax near "saledate". I'm thinking it isn't valid in SQL 6.5, in which case I'll have to fart about dropping tables and such I guess? Anyone got a quick guide to that? bah

      Comment


        #4
        Anyone? I'm bored at work trying to get round this (in the middle of other things)

        Comment


          #5
          RTFM? I'm no SQL Server person, but if it isn't working in 6.5, I have to wonder if they were able to do drop column statements back then.

          Comment


            #7
            That's pretty standard. DB2 is the same. You can add columns but can't drop them.

            Comment


              #8
              Why dont you create a table and

              CREATE TABLE Table_B AS

              (SELECT Colum.a, Colum.b, Colum.c FROM Table_A)


              Just pick which Ever Colums you need and leave the ones you want to drop

              Easy !
              Last edited by Gerry Helmet; 18-02-2005, 09:11.

              Comment


                #9
                Originally posted by charlesr
                That's pretty standard. DB2 is the same. You can add columns but can't drop them.
                I was just reading up on this. The alter table drop column syntax is part of the ANSI SQL 92 standard, and it's supported by SQL Server (since 7.0), Oracle (for as long as I can remember, 7 at least), Postgress, Sybase, even MySQL! DB2 is probably the only DB that still doesn't support it, not what I would call standard.

                Comment


                  #10
                  New table, copy, drop old table, rename new table!

                  That's the plan then...

                  Comment


                    #11
                    If you use that Simplie code i put up , that will copy all the Data from the colums you have specified. Then just drop the old one and rename the new one all of 5 minutes !

                    Comment

                    Working...
                    X