abap 的資料庫增刪改查

2022-03-30 20:13:58 字數 960 閱讀 8018

資料庫中插入新條目。

1.插入單行資料:

insert into dbtab values wa.

insert into dbtab from wa.

wa為工作區,是與資料庫具有相同結構的資料物件,一般直接基於資料庫結構宣告。該語句也可以將資料插入檢視中,首先該檢視所有字段必須來自同乙個資料庫表,而且在資料字典中的maintenance status屬性必須設定為read and change

注:如果相同表關鍵字的資料條目已經存在,則不能重新插入,只能對非關鍵字進行更改(update,modify)

2.插入多行資料

insert dbtab from tables itab.

其中itab是內錶,包含希望插入的資料條目。

注:內錶應與資料庫的行結構一致。

所有條目成功插入,則sy-subrc返回0

使用accepting duplicate可避免該錯誤。

insert dbtab from table itab accepting duplicate keys. 

accepting duplicate的效果是:若出現關鍵字相同,返回4,並跳過其再更新所有的其他。

四.delete語句

1.刪除單行資料:

delete from dbtab where .

或 delete dbtab from wa.

其中where必須指明全部表關鍵字段的值;wa為工作區,若不去dbtab匹配操作將失敗。

2.刪除多行資料:

delete from dbtab where .

delete dbtab[client specified] from table itab.

注:返回值同modify

3.刪除多行資料:

兩種形式:1).通過內錶刪除多行資料條目的過程中將內錶置為空;2).使用where field like '%'。

**:

資料庫增刪改查

我們知道當我們的表建立後重複執行會出錯,一般我們會這麼處理 create table if not exists stuinfo 學了新建表我們還應該知道乙個東西,如何刪除表 deop table table name 怎麼檢視別人的見表語句呢 show create table stuinfo 怎...

資料庫增刪改查

import pymysql def getmysqlconn conn pymysql.connect host 172.16.238.130 port 3306,db my mysql user root password 123456 charset utf8 return conn def ...

資料庫增刪改查

資料庫操作 show databases create database 資料庫名 use 資料庫名 select database drop database 資料庫名 資料表操作 create table 表名 欄位名 型別名 約束 show tables drop table 表名 資料表增刪...