一.今日学习内容 1.新建表格 类型 varchar----字符串 int---普通大小的整数 tinyint---很小的整数 smallint---小的整数 id 自动递增 主键:唯一表示 2.增删改查(crud) 增加 insert into 表名(字段1,字段2) values (值1,值2); insert into stu (name,age) values('add',12); 删除 delete from 表名 [where 条件]; 中括号里的内容:在技术文档中代表可写可不写 不写:删除表中的所有的数据 delete from stu where name='add'; 更新 update 表名 set key1=value1,key2=value2 [where 条件]; update stu set name='测试2' where id=15; 查询 select 字段列表或者* from 表名 [where 条件]; select name,age,address from stu where id=1; 3.高级查询 =,>,<,>=,<=,<>不等于 字段 between a and b :在某个范围内 select * from stu where age between 18 and 25; like ‘%内容%’:搜索某种模式,模糊查询 select * from stu where name like '%小%'; order by 字段 [desc] :排序 select * from stu order by age desc; and 且 select * from stu where age>20 and name like '%小%'; limit m,n 跳过m条查询n条 select * from stu age limit 2,5;
|