本章主要展示关于数据维护与结构的代码参考,比如INSERT、INSERT FROM SELECT …、DELETE … WHERE …、UPDATE … WHERE …、CREATE/DROP TABLE、ALTER TABLE、KEYS、CONNECT/DISCONNECT/COMMIT/ROLLBACK等。
|
A |
|
1 |
=demo.query("select * from SCORES") |
|
2 |
=A1.insert(0,"Class one",20,"PE",100) |
追加新记录 |
3 |
=A1.insert(5,"Class one",21,"PE",100) |
插入新记录 |
|
A |
|
1 |
=demo.query("select * from SALES") |
|
2 |
=A1.derive() |
复制序表 |
|
A |
|
1 |
=demo.query("select ORDERID,CLIENT,SELLERID, ORDERDATE,AMOUNT from SALES") |
|
3 |
=A1.delete(A1.select(AMOUNT<10000)) |
删除满足条件的记录 |
|
A |
|
1 |
=demo.query("select ORDERID,CLIENT,SELLERID, ORDERDATE, AMOUNT from SALES") |
|
2 |
=A1.select(CLIENT:"HL").run(AMOUNT= int(AMOUNT*1.1)) |
按条件修改数据 |
|
A |
|
1 |
=create(ProductNo,ProductName,UnitPrice,Quantity) |
创建新序表 |
2 |
>A1=null |
清除序表 |
|
A |
|
1 |
=demo.query("select * from EMPLOYEE") |
|
2 |
=A1.rename(EID:ID) |
修改字段名 |
|
A |
|
1 |
=demo.query("select * from EMPLOYEE") |
|
2 |
=A1.keys(EID) |
设置主键 |
|
A |
B |
|
1 |
=connect@e("demo") |
|
建立连接 |
2 |
>A1.execute@k(...) |
|
|
3 |
=A1.error() |
|
上一条数据库执行的错误信息 |
4 |
if A3==0 |
>A1.commit() |
无错则提交 |
5 |
else |
>A1.rollback() |
有错则回滚 |
6 |
>A1.close() |
|
关闭连接 |