Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help droping a column in a table. 1

Status
Not open for further replies.

Sina

Technical User
Jan 2, 2001
309
CA
Hello every one.

I have installed DB2 on NT 2000 as a test system. Created a simple table with 4 columns. when I use the command center,
db2 connect to sample
its fine.

I have created the tabel mytable1 in Sample.

Using both the control center and the command processor, I simply can not drop any of these columns. I also tried the other tables, like emp and others, and the same thing.

Any idea?
I have used both

Alter table mytable1 drop col1

I know of the following. but my table is very simple, no primary key or constraints.

Also tried the following, even though I know it does not apply to to mytable.

If any one can help, I would appriciate it.

thank you so much
 
Review the docs on ALTER TABLE. There is no ALTER TABLE DROP COLUMN in DB2.

RENAME TABLE yourtab to yourtab_old;

If the table is small:
CREATE TABLE yourtab
(table def without unwanted column)
AS
(SELECT [column_list] from yourtab_old);
commit;

For larger tables:
CREATE TABLE yourtab (table def without unwanted column);

Use DB2 EXPORT/IMPORT to export data from yourtab_old, and use import to load the data into yourtab.
 
Thank you for your reply.
I'm new to db2.

so Is that correct to say, I can not drop a column from an existing table?

I come from sql server, so I tried using the control center in db2, added a column to a table, pressed the ok button, went back and tried to delete the column that I had added, and the remove key is grayed out.

is that because I can not drop a column from a table once it has been created.

Thank so very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top