Skip to Content
-1

Delete contents of table column

Mar 13 at 10:47 AM

85

avatar image

Hi,

I have a database table with approx 63 million records.

I have to delete the contents of 2 specific columns prior to running a piece of code.

Is there a delete statement for deleting the contents of only certain columns while still retaining the columns in the structure of the table?

Wouldn't the update statement have to be run for every row , thus affecting performance if used to replace data with a blank in a certian column?

Regards,

Cleo

10 |10000 characters needed characters left characters exceeded

Hmm, the business case sounds a bit strange, deleting columns of a database table before "running a piece of code". And all the other code accessing the table?

0

Actually it is a Ztable used for simulation of prices in SAP BW. 2 columns of the Ztable which get filled post running code requires to be blank mandatorily before the code is run. So have to delete the contents of the these 2 columns. This table is active table of a Z-DSO. it is not used by any other code.

0

"requires to be blank mandatorily before the code is run."

What requires them to be blank? Why can the field values simply not be overwritten? Seems odd.

0

these columns are flags which would be 'X', but we have to delete all the 'X's and make them blank.

0

From my understanding Cleo James does not need to delete the columns - the requirement is to clear some columns of some particular rows.

Why not just using an UPDATE with a WHERE clause?

1

does below statement go row by row or in one swoop for the whole database table?

update DBTABLE1 set col1 = 0, col2 = ' '.

0
0

In German?

0
0

Have you tried it with UPDATE SET and checked if there is a performance problem?

0
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Sandra Rossi Mar 14 at 07:24 AM
2

An Open SQL statement is at the end operated by your database system, so go to the forums/documentation of the software vendor (Oracle, SAP HANA, Microsoft Server SQL, IBM DB/2, etc.)

But of course UPDATE ... SET ... is a well known SQL statement, which does a mass update, not one by one. In fact, technically, it will always be one by one, but it's not at the ABAP side of course, and it's always more performing than multiple updates.

Note that you may also define in the DDIC an update database view so to select only the primary key and columns you want to update, and do the UPDATE ... FROM TABLE update_database_view.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

I imagine if the table in question is a column store on a HANA database, it will be very fast.

1
Matthew Billingham
Mar 14 at 07:29 AM
1

Create a new DSO without the two fields. Create a transformation and DTP from DSO1 to DSO2 - direct map, push down to HANA if you're at the right level and are using HANA. Create another transformation and DTP from DSO2 to DSO1.

Now, in your process chain, run the first DTP, drop DSO1 using CL_SQL_STATEMENT for native SQL, run the second DTP.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Why do I have this image of hammers and walnuts in my head? :-)

0

I couldn't possibly imagine. ;-D

0
avatar image
Former Member Mar 13 at 01:09 PM
-1

I believe there is no another way to update each row in the table.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Mar 14 at 01:25 AM
-1

Yes. There is no way without UPDATE SET statement.

Show 5 Share
10 |10000 characters needed characters left characters exceeded

but how does the UPDATE SET statement work? the SET column feature goes row by row for changing 1 column or just sets all the rows in the whole column at once?

0
Former Member

Hello James,

I am not sure why you are more concern whether it will update row by row (or) all the rows at once. This will be depend the DB that we are using.

The general syntax will be as below.

UPDATE ZMYTABLE SET DESC_FIELD = 'My test description in english'
            WHERE spras = 'EN' .

Commit work. 
0

ouch, direct update of a standard table? Can't you just take a Z table name for your example...

0

Edited it.

@Praveen - you don't really update standard SAP tables like MAKT directly do you?

0
Former Member

Hi , I just tried to explain the keyword UPDATE SET . I don't do this in our productive environments :(

Anyhow I will use Z tables for examples. :)

Thanks ,

Praveen.

1