添加数据格式,不考虑主键------> 格式: insert into 表名 (列名) values (值)
添加数据格式,所有值全给出------> 格式: insert into 表名 values (全列值) 注意:值主键也得写
添加数据格式, 批量写入 ------> 格式:insert into 表名 (列名1,列名2,列名3)values (值1,值2,值3),(值1,值2,值3),(值1,值2,值3)...
更新数据 ,在原有数据的基础上修改 格式: update 表名 set 列1=值1,列2= 值2 where 条件 (条件找数据中的唯一性)
<> 不等于 = <= >= 没有== 与: and or 非 :not
id in (1,3,4,5,6) 表示id 为1,3,4,5,6 都被修改
删除表中的数: 格式: delete from 表名 where 条件 一条一条删,不清空主键记录数
truncate table 表名 直接将表删除,重新建表, 主键从零开始
命令行改乱码问题 : set names 'gbk'
*****SQL 查询语句: 查询指定列的数据--->格式: select 列名1 ,列名2 from 表名 查询所有列的数据--->格式: select * from 表名 查询去掉重复记录--->格式: select distinct 跟随列名 from 表名 查询重新命名列---->格式: select 列名 as 新列名 from 表名 查询数据中直接进行数学计算:---->select 列名, 列名 +数字 from 表名
between ... and ... 在...之间, 要求前面的数比后面的小 也可以做日期查询 like 模糊查询 配合通配符 select * from 表名 where 列名 like ' % ... %'
select * from 表名 where 列名 like '-----' (一个下划线等于一个字符)
查询 不为空的
*方式1 :select * from 表名 where 列名 is not null
方式2 :select * from 表名 where not (列名 is null )