数据库MYSQL基础知识框架
2022-10-27 21:44:27 0 举报
AI智能生成
登录查看完整内容
数据库MYSQL基础知识框架
作者其他创作
大纲/内容
例:端口: 3306 tasklist | find ;quot;mysqld;quot; netstat -an |find ;quot;3306
查询
;mysql -u root -p;注意:环境变量的设置
登录
show databases; select database(); use test; show tables; select * from goods;
基础命令
表的创建
;语法:drop table 表;
表结构的删除
语法:insert into 表 values 值; 语法:insert into 表(列1,列2...) values(值1,值2...);
新增
语法:update 表 set 列=值 where 条件;
修改
语法:delete from 表 where 条件; 语法:truncate table 表;
删除
查询可以查询指定的行,指定的列,指定行的列语法:select 列 from 表 where 条件;*是代表表中所有的列名
ECShop
语法:select 列 from 表 where 条件;
例子:查询ecs_goods表中本店售价高于2000的所有商品信息 select * from ecs_goods where shop_price;gt;2000; 例子:查询ecs_goods表中商品名称不是KD876的所有商品信息 select * from ecs_goods where goods_name;apos;KD876;apos;;
1.比较运算 ;gt; 大于 ;lt; 小于 = 等于 ;gt;= 大于等于 ;lt;= 小于等于 != 不等于 不等于
比较运算
例子:查询ecs_goods表中本店售价范围2000和3000之间的所有商品名称 select goods_name from ecs_goods where shop_price;gt;=2000 and shop_price;lt;=3000; 例子:查询商品名称是KD876或者诺基亚的所有信息 select * from ecs_goods where goods_name=;apos;KD876;apos; or goods_name=;apos;诺基亚;apos;;
关系运算 and 同时满足条件 or 满足一个条件即可 not 不满足条件
关系运算
例子:查询ecs_goods表中本店售价范围2000和3000之间的所有商品名称 select * from ecs_goods where shop_price between 2000 and 3000;
between ...and ... 注意:小在前,大在后,包括两个端点
区间
查询ecs_goods表中商品名称诺基亚开头的所有商品信息select * from ecs_goods where goods_name like ;apos;诺基亚%;apos;;查询ecs_goods表中商品名称6结尾的说有商品名称select goods_name from ecs_goods where goods_name like ;apos;%6;apos;;查询ecs_goods表中商品名称是6个字符的所有信息select * from ecs_goods where goods_name like ;apos;______;apos;;
当信息不完整时候使用模糊查询,多数是和字符类型一起使用like_ 一个字符% 任意个字符
模糊查询
例子:查询ecs_goods表中suppliers_id不为空的所有信息 select * from ecs_goods where suppliers_id is not null;
空值查询
in查询
补充
where查询
数据操作
表
数据库
mysql基础
数据库MYSQL基础知识框架
0 条评论
回复 删除
下一页