当前位置:Gxlcms > 数据库问题 > [常用的Sql语句总结]

[常用的Sql语句总结]

时间:2021-07-01 10:21:17 帮助过:17人阅读


 6. 表操作(添加数据)

添加内容 : insert into 表名称 values(内容1,内容2,...)
多条添加 : insert into 表名称 values(内容1,内容2,...),(内容1,内容2,...)
添加部分 : insert into 表(字段,字段,...) values(值,值,...)
添加多条 : insert into 表(字段,字段,...) values(值,值,...),(值,....)

部分导入 : insert into 表1(列名1,列名2) select (列名1,列名2) from 表2              //从表 2中查询数据添加至表1中 ,values 不用写

批量导入:  insert into 表2 select * from  表1          //把表1的数据导入到表2中,仅数据,无结构


 7. 表操作(更改数据): 

单列修改 : update 表 set 字段=值
多列修改 : update 表 set 字段=值,字段=值
带条件改 :update 表 set 字段=值,字段=值 where 条件(逻辑词:= >= between...and ,and , or, in ...)
空条件改 :update 表 set 字段=值 where 字段 is null

8.表操作(删除数据):
带条件删 : delete from 表 where 条件
空条件删 : delete from表 where 字段 is null
删除所有 : delete from 表 [只删除表里面的数据 不删除表]

[常用的Sql语句总结]

标签:drop   建表   where   批量导入   base   percent   字段   delete   删除表   

人气教程排行