一、SQL分类
--------------------------------------------------------------------------------------
1、按操作分类:DDL和DML
2、按是否有缓存分类:
(1) OPEN SQL :数据库与命令编译器存在缓存,如Select * From <Itab>....
(2) Native SQL:直接处理
二、创建字典表
--------------------------------------------------------------------------------------
语法:TABLES table
三、处理字典表
--------------------------------------------------------------------------------------
1、查询
------------------------------
语法:SELECT <result> FROM <source> [INTO <target>] [WHERE <condition>]
[GROUP BY <fields>] [ORDER BY <sort_order>].
2、插入
------------------------------
(1) Work Area插入:
语法:INSERT INTO <database> VALUES <wa>
(2) 表间插入
语法:INSERT <database> FROM TABLE <itab> [ACCEPTING DUPLICATE KEY]
3、更改
------------------------------
(1) 更改单行
语法:UPDATE <dbtab> [CLIENT SPECIFIED] FROM <wa>.
或
UPDATE <dbtab> [CLIENT SPECIFIED].
(2) 更改多行
语法:UPDATE <database> SET < f1>=<values>… WHERE <condition>.
(3) 表间更改
语法:UPDATE <dbtab> [CLIENT SPECIFIED] FROM TABLE <itab>.
(4) Modify更改(有则更改,无则插入)
语法:MODIFY <database> FROM <wa>.
4、删除
------------------------------
(1) 使用关键字删除
语法:DELETE <database> FROM <wa>
(2) 使用条件删除
语法:DELETE FROM <database> WHERE <condition>
5、使用游标
------------------------------
(1) 打开:
语法:OPEN CURSOR <c> FOR SELECT … WHERE <condition>
(2) 使用:
语法:FETCH NEXT CURSOR <c> INTO <wa>
(3) 关闭:
语法:CLOSE CURSOR <c>
四、提交与回退
--------------------------------------------------------------------------------------
(1) 提交:COMMIT WORK
(2) 回退:ROLLBACK WORK