copy_rows¶
- async AsyncDataTableOracle.copy_rows(where, field_map=None, distinct=False)¶
拷贝当前表的数据行
按照指定where条件,copy数据到本表, 可以通过field_map更新或者指定部分字段的值。(常用于版本拷贝)
- 参数
示例
import pypika.functions as pf tbl = DataTableMySQL("test") t = tbl.table tbl.copy_rows( where=(t.f1 >= 1) & (t.f2 == 2) | (t.f3 > 1), field_map={ "f1": t.f1 + 1, "f2": 3, "f4": t.f5, "f6": pf.Max(t.f6) } )
将执行sql:
INSERT INTO test SELECT `f1` + 1 as f1, 3 as f2, `f3`, `f5` as f4, `f5`, Max(`f6`) as `f6` FROM test WHERE `f1`>=1 AND `f2`==2 OR `f3`>1