Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Delete clause clarification

Former Member
0 Likes
2,584

To delete data in one shot from database table...

delete dbtable not working..

IS it necessary to use where clause?

plz help me out

15 REPLIES 15
Read only

Former Member
0 Likes
2,498

Hi

You can't use the command DELETE alone, becouse you have to indicate which record you want to delete, so:

A)

SELECT * FROM <TABLE> WHERE...

DELETE <TABLE>.

ENDSELECT.

B) DELETE FROM <TABLE> WHERE ......

C) DATA WA LIKE <TABLE>.

.......

DELETE <TABLE> FROM WA

D) DATA ITAB LIKE STANDARD TABLE OF <TABLE>.

..........

DELETE <TABLE> FROM TABLE ITAB.

Max

Read only

0 Likes
2,498

Max thanks a lot for ur reply.

My requirement is just deletion of total data in one shot from database table thru abap program.

DELETE dbtable ...is for one row delete only?

suggest me query for this requirement...

i award u points also...

thank u

Read only

0 Likes
2,498

and moreover...i dont want to use any itabs...in this issue

Read only

0 Likes
2,498

Ok

you use this statatment without where conditions:

DELETE FROM <TABLE>.

Max

Message was edited by: max bianchi

Read only

Former Member
0 Likes
2,498

Hi Raja,

"delete dbtable" will work if you have defined

"Tables dbtable" and this will delete only record that matches the workarea dbtable.

To delete in one shot -

DELETE FROM DBTABLE.

But if its a client soecific table it will delete data in current client only . If you want to delete data in all clients use "client specified".

Cheers

Read only

Former Member
0 Likes
2,498

Hi,

If you want to delete all table entries without ABAP coding, go to tr.code SE11 -> Utilities -> Database utility (Transaction SE14).

Svetlin

Read only

Former Member
0 Likes
2,498

Hi Max & Sanjay,

DELETE from dbtab not working...

Syantax error: delete from itab shud be followed by where clause...

Help me out.

I have to do this programatically..

Read only

0 Likes
2,498

sorry error msg : delete from dbtab shud be followed by where clause...

Read only

Former Member
0 Likes
2,498

GOT it from documentation.

check the following

<b>Note:</b>

To delete all the lines in a table, you must specify a WHERE condition that is true for all lines. You can achieve this with

... WHERE f IN itab

If the internal table itab is empty, such a condition would select all lines.

Read only

0 Likes
2,498

Hi

I'm using 4.7, in this release you can use thie statament without where condition...I'm sorry, you can try to do:

DELETE FROM TABLE CLIENT SPECIFIED

WHERE MANDT = SY-MANDT.

I try to use this statament in 4.6C and no error has occured.

Max

Read only

Former Member
0 Likes
2,498

Can anybody suggest me with out using where clause to delete table data in one shot..?

Thanks

Read only

0 Likes
2,498

For non crossclients tables you can try with.

DELETE FROM <DBTABLE> CLIENT SPECIFIED WHERE MANDT = SY-MANDT.

Svetlin

Read only

0 Likes
2,498

you can use

delete from <dbtable> .

to delete all entries. it works fine. I just tried it out.

we are using 4.7

Regards

Raja

Read only

0 Likes
2,498

As others pointed out here, you can delete without using the where clause from 47 onwards. Why is that you don't want to use the where clause? It is as simple as

DELETE FROM dbtab WHERE <some key field> <> SPACE.

Read only

Former Member