內錶增刪改查操作

2021-06-16 05:06:10 字數 3108 閱讀 8024

一、單行增加

data: begin 

of line,

land(3)  type c,

name(10) type c,

age      type i,

weight   type p decimals 2,

end 

of line.

data itab like 

sorted 

table 

of line

with 

non-unique 

key land name age weight.

data jtab like sorted table of line.

line-land = 'g'.   line-name   = 'hans'.

line-age  = 20.    line-weight = '80.00'.

insert 

line 

into 

table itab. "增加記錄

二者區別:

2.對於排序表而言,插入行不可以打亂關鍵字的排序順序,否則報錯。

3.對於雜湊表而言,插入過程中系統按照關鍵字對行進行定位。

二、多行增加

insert lines of itab into table jtab.

三、單行統計增加

line-col1 = 'abc'. line-col2 = '12'. line-col3 = 3.

collect line into itab.

line-col1 = 'def'. line-col2 = '34'. line-col3 = 5.

collect line into itab.

line-col1 = 'abc'. line-col2 = '12'. line-col3 = 7.

collect line into itab.

注意:此時itab必須有key。collect根據key相同對其他資料進行累加

一、單行刪除
delete table itab with table key col1 = 3.(itab必須有key,因為刪除出問題很大,不能隨便刪除一行)
二、條件多行刪除

delete itab where ( col2 > 1 ) and ( col1 < 4 ).

三、刪除重複行

delete adjacent duplicates from itab comparing all fields.

一、單行修改

line-col1 = 2.

line-col2 = 100.

modify table itab from line.(只能修改一行,如果沒指定key,則第一行進行了修改)
如果不指定key,也可以:
modify itab index 1.
二、多行修改

data itab like 

hashed 

table 

of line 

with 

unique 

key col1.

do 4 times.

line-col1 = sy-index.

line-col2 = sy-index ** 2.

insert 

line 

into 

table itab.

enddo.

line-col2 = 100.

modify itab from 

line 

transporting col2(必須指定傳哪個字段值,否則報錯)

where ( col2 > 1 ) and ( col1 < 4 ).

一、單行查詢
data: begin 

of line,

col1 type i,

col2 type i,

col3 type i,

end 

of line.

data itab like 

hashed 

table 

of line 

with 

unique 

key col1.

do 4 times.

line-col1 = sy-index.

line-col2 = sy-index ** 2.

line-col3 = line-col1 * line-col2.

insert 

line 

into 

table itab.

enddo.

line-col1 = 2.

line-col2 = 3.

line-col3 = 4.

read 

table itab from 

line 

into 

line.(如果不指定key,則讀取第一行)

二、單行查詢(查詢到後指定傳遞值的字段)
data: begin 

of line,

col1 type i,

col2 type i,

end 

of line.

data itab like 

sorted 

table 

of line 

with 

unique 

key col1.

do 4 times.

line-col1 = sy-index.

line-col2 = sy-index ** 2.

insert 

line 

into 

table itab.

enddo.

clear line.

read 

table itab with 

table 

key col1 = 3

into 

line 

transporting col2. (指定只傳遞col2的值,不傳遞col1)

mysql增刪改查鍊錶 鍊錶的增刪改查

include include 先定義鍊錶裡面的元素。typedef struct nodemynode 定義整個鍊錶。typedef struct linkmylink int isempty to mylink mylink mylink 判斷鍊錶是否為空。int push to mylinki...

表的增刪改查

insert into 表名 引數列表 values 值列表 批量插入 insert into 表名 引數列表 values 注意 型別,範圍,值一一對應 隱含列時,插入每列對應的值 指定列插入 只給表中的某幾個字段賦值 指定列要說明 指定欄位名 當插入的資料主鍵存在衝突時 更新操作 insert ...

鍊錶 增刪改查

實現 鍊錶的增刪改查 package com.baicai.linkedlist public class singlinkedlistdome 定義乙個singlinkedlist管理我們的英雄 class singlelinkedlist 如果沒有找到最後的乙個節點就直接往後面找 temp te...