Can someone tell me how to remove a column from a table using SQL?
Thanks
RHNewfie There are 3 Types of People in the World
Those Born to Think Logically
Those that can Learn to Think Logically
Those that Shouldn't Try
I don't believe there is a way to just drop a column from a table. Probably due to the possible effect on Primary and Foreign Keys (Referential Integrity as a whole.)
You'll need to do this:
Create table NewTable(
ID integer,
Data1 Char(9),
Data2 Char(16),
Amount Decimal (13,2) )
;
Then DO
Insert into NewTable
Select ID, Data1, Data2, Amount
From OldTable
;
Where you don't copy the unwanted column over to NewTable
Then Do
You are correct, I ended up copying the data, dropping the table, recreating the table and then repopulating it with the data I wanted to have left behind and reestablicshing foreign keys. Seems like a hokey way to have to do it but it works.
Thanks
RHNewfie There are 3 Types of People in the World
Those Born to Think Logically
Those that can Learn to Think Logically
Those that Shouldn't Try
While moving your records, I don't suggest using SQL statements,instead use the "export" function in control center then try using the "load".It is more reliable and very much faster. Salih Sipahi
Software Engineer.
City of Istanbul Turkey
openyourmind77@yahoo.com
Do you need to reconstruct your table from your clients???
I don't think it is secure.You should never grant your users to drop your database tables.These transactions should be performed in local or remote DB2 systems.
Export and import commands are in the control center part of your DB2 software.
Open your control center,then yoru database and open your tables.Select your table click right mouse and select export.Fill the required fields then in your target table you can both perform the import or load functions.
You can find documnets in information center of DB2 software Salih Sipahi
Software Engineer.
City of Istanbul Turkey
openyourmind77@yahoo.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.