ABAP数据库操作- 删除数据 DELETE

  • Post author:
  • Post category:其他


https://blog.csdn.net/f346348157/article/details/124076948

在SE11创建一个表zlion_test,字段:学号、姓名、性别、年龄,并在SE16N中添加5条记录

1、delete where 单/多行删除

REPORT zcsdn_lion_db04.

DELETE FROM zlion_test WHERE xh = 1.”单条删除

DELETE FROM zlion_test WHERE age > 30.”多条删除

1

2

3

4

2、delete from 工作区

REPORT zcsdn_lion_db04.

DATA i_wa TYPE zlion_test.

i_wa-xh = 1.

DELETE zlion_test FROM i_wa.

1

2

3

4

5

6

3、delete from table

REPORT zcsdn_lion_db04.

DATA i_wa TYPE zlion_test.

DATA i_tab TYPE STANDARD TABLE OF zlion_test.

i_wa-xh = 1.

APPEND i_wa TO i_tab.

i_wa-xh = 2.

APPEND i_wa TO i_tab.

i_wa-xh = 4.

APPEND i_wa TO i_tab.

DELETE zlion_test FROM TABLE i_tab…

IF sy-subrc = 0.

ENDIF.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

备注:delete from table 删除多行时,只要其中有一条不存在的记录,sy-subrc返回的都是非0,所以不能以sy-subrc=0来判断是否删除成功

4、区别

用where删除语句是:delete from table where 条件

非where删除语句是:delete table from 工作区/table

请注意上面的 from table 和 table from的位置



版权声明:本文为weixin_43847969原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。