Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2004
    Posts
    35

    Unanswered: Deleting a column using Alter

    I have table with data in it. in that table, I want to delete 2 columns (These columns are not part of any key)

    How can I do that?

  2. #2
    Join Date
    Apr 2003
    Location
    Minneapolis, MN
    Posts
    273
    ALTER TABLE <tab_name>
    DROP COLUMN col1, col2;
    Bhavin

    MS Computer Science
    OCP DBA 9i/8i

  3. #3
    Join Date
    Apr 2003
    Location
    Minneapolis, MN
    Posts
    273
    If you just want to delete the data in those column and keep the column in the table, then

    UPDATE <tab_name>
    SET col1 = NULL, col2 = NULL;
    Bhavin

    MS Computer Science
    OCP DBA 9i/8i

  4. #4
    Join Date
    Feb 2004
    Posts
    35
    I did just that.. But got an error ORA-00933 - SQL command not properly ended

    alter table dd_country drop column importrulesetkey, exportrulesetkey;

  5. #5
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    It seems from the SQL Reference manual that there are 2 subtly different comands:

    alter table t drop column c;

    alter table t drop (c, d, ...);

    So for yours:

    alter table dd_country drop (importrulesetkey, exportrulesetkey);

    Confusing, but documented:

    http://download-west.oracle.com/docs...2a.htm#2103928

  6. #6
    Join Date
    Feb 2004
    Posts
    35
    I executed

    alter table dd_country drop (importrulesetkey, exportrulesetkey);

    but, I get an error now..

    ORA-00942: table or view does not exist

    I checked and the table is available and it has data in it too...

    I thought this is pretty simple..But, ghaaaaleee I did not expect so much for this

  7. #7
    Join Date
    Oct 2003
    Location
    St.Louis,MO
    Posts
    120
    Originally posted by durbhakula
    I executed

    alter table dd_country drop (importrulesetkey, exportrulesetkey);

    but, I get an error now..

    ORA-00942: table or view does not exist

    I checked and the table is available and it has data in it too...

    I thought this is pretty simple..But, ghaaaaleee I did not expect so much for this
    Just for grins,
    did you try
    alter table "dd_country" drop (importrulesetkey, exportrulesetkey);
    and do you have rights for this table? Logged in as table owner?

  8. #8
    Join Date
    Feb 2004
    Posts
    35
    Yes I do have all the permissions..

    And I tried the option that you were suggesting me.."dd_country"

    doesn't work

  9. #9
    Join Date
    Feb 2004
    Posts
    35
    I got it....

    The table that I was trying to alter has a different owner (I did not have sysnonyms). So, I had to qualify my table with the OWNER name in it.

    Thanks Guys..

Posting Permissions

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