zoukankan      html  css  js  c++  java
  • SqlServer——批量操作(批量添加,删除)

    批量添加数据:

    一条insert语句批量插入多条记录

    常见的insert语句,向数据库中,一条语句只能插入一条数据:

    insert into persons 

    (id_p, lastname , firstName, city )

    values(204,'haha' , 'deng' , 'shenzhen');

    (如上,仅插入了一条记录)

    怎样一次insert插入多条记录呢?

    使用示例:

    insert into persons 

    (id_p, lastname , firstName, city )

    values

    (200,'haha' , 'deng' , 'shenzhen'),

    (201,'haha2' , 'deng' , 'GD'),

    (202,'haha3' , 'deng' , 'Beijing');

    这样就批

    据说,在程序开发中,一次插入多条数据,比逐次一条一条的插入数据,效率高很多

    所以在程序开发的时候,使用此批量插入,也是比较不错的。

    此语句在MySQL 5, postgreSQL 9.3执行通过。

    量插入数据了, 遵循这样的语法,就可以批量插入数据了。

    ===================================================

    批量删除数据:

    delete from table where id in (xxxxxxxx) 

     truncate table 表名;//彻底删除,再插入数据就会从1开始

  • 相关阅读:
    orm添加表记录
    创建多表模型
    包的使用
    日志写法
    os模块,是通过和操作系统交互进行操作
    sys python解释器做交互
    软件开发规范
    模块 time模块 datatime模块 random模块
    装饰器
    装饰器进阶
  • 原文地址:https://www.cnblogs.com/shuai7boy/p/5809143.html
Copyright © 2011-2022 走看看