1.UPDATE(修改操作)
UPDATE实现对数据的更新操作,语法如下:
UPDATE <dbtab> SET f1...fn (WHERE <condition>).
UPDATE <dbtab> FROM TABLE <itab> (WHERE <condition>).
[For Example]
UPDATE SPFLI SET:AIRPTO = 'MONTREAL-DO' WHERE CARRID = 'AC '.
UPDATE SCUSTOM SET:DISCOUNT = '003',LANGU = 'ENGLISH',REGION = 'SEATTLE',TELEPHONE = '888888' WHERE ID = 38.
以要語句居然將數據庫中的所有字段都更新成一樣,查了下資料網上也有童鞋有同樣的問題。故將語句改成以下去掉字段間的分號即可。
UPDATE SCUSTOM SET: TELEPHONE = '86111' NAME = 'TOM KIY' LANGU = 'ENGLISH' REGION = 'SEATTLE' WHERE
ID = '12400177'.
2.INSERT(插入数据)
INSERT语句用于对数据的新增操作,语法如下:
INSERT INTO <dbtab> VALUES <conditin>.
INSERT <dbtab> FROM TABLE <itab>.
[For Example]
TABLES SCUSTOM.
SCUSTOM-ID = '11279'.
SCUSTOM-NAME = 'JACK BLOGS'.
SCUSTOM-POSTCODE = '658896'.
SCUSTOM-CITY = 'SIGAPO'.
INSERT INTO SCUSTOM VALUES SCUSTOM. "从某一结构体获取新增数据
*INSERT SCUSTOM. "直接对表HEADER LINE赋值新增
TABLES SAIRPORT.
SAIRPORT-ID = 'KIT'.
SAIRPORT-NAME = 'NEW ZLAND'.
INSERT SAIRPORT. "直接对表HEADER LINE赋值新增
3.DELETE(删除操作)
DELETE 语句用于删除表中的数据,语法如下:
DELETE FROM <dbtab> WHERE <condition>.
DELETE FROM <dbtab>.
DELETE <dbtab> FROM TABLE <itab>.
[For Example]
TABLES SCUSTOM.
DELETE FROM SCUSTOM WHERE ID = '12400177' AND POSTCODE = '888888'. "按条件删除数据
SCUSTOM-ID = '11278'.
SCUSTOM-NAME = 'BILL'.
DELETE SCUSTOM. "按结构体条件删除表数据,按内表数据进行删除基本类似
4.MODIFY操作
MODIFY操作是用于修改数据库中的数据。与UPDATE操作不同的是,如何表中不存在符合条件的数据时会添加一样新数据。也就是说MODIFY拥有 INSERT 和 UPDATE的操作动作。不过通过MODIFY修改的数据效率比较低下,远不如UPDATE和INSERT操作。语法如下:
MODIFY <dbtab>.
MODIFY <dbtab> FROM TABLE <itab>.
[For Example]
TABLES SCUSTOM.
SCUSTOM-ID = '186999868'.
SCUSTOM-NAME = 'DAYRON ROBLES'.
SCUSTOM-POSTCODE = '39866'.
SCUSTOM-CITY = 'CUBA'.
MODIFY SCUSTOM. "该表以ID为主键,此时数据库中没有符合ID='186999868'的数据,故先插入一条。如下图:
*接着MODIFY该条数据。
TABLES SCUSTOM.
SCUSTOM-ID = '186999868'.
SCUSTOM-NAME = 'DAYRON ROBLES'.
SCUSTOM-POSTCODE = '39866'.
SCUSTOM-CITY = 'CUBA'.
MODIFY SCUSTOM. "此时数据库中存在ID='186999868'的数据,故将其更新。如下图: