net start/stop [service name] 启动/中止某种服务mysql
mysql [-h host_name -p port_number] -u user_name -p 回车后输入密码sql
基本相关 :良好的书写习惯,每条sql命令后添加" ; "做为标识数据库
#注释内容
或者 -- 具体注释内容 (注意中间含有一个空格)
SQL语言; DDL , DML , DCL(TCL) , DQLwindows
一些关键字&函数:安全
as 重命名字段名 select col_1 as rename_col from table_name ; 也能够使用空格代替函数
concat() 用于链接两个字符串 : select concat(字段1, 字段2) from table_name; 若函数中有一个参数为空,则最终结果显示为NULL,为避免此种状况出现,在可能为空的字段外套用:
isnull(field_name,为空时的替代值) 函数学习
length(str) 提取字符串字节长度,char_length(str) 以字符为度量单位返回str长度。ui
其他字符串函数如:trim系列函数,left,right函数,lpad,rpad函数,substr函数,space函数,strcmp等字符串相关函数,now,curdate,date_format,get_format等日期函数,if,case等系列字符流控制函数以及其余函数,须要时可翻阅手册12章。spa
distinct 筛选不重复的数据值 select distinct col_name from table_name;3d
where 用于条件查询.
关系表达式 : > , < , >= . <= , = , <> (不等于,通常不使用 != ) ;
逻辑运算符 : and or not 也可表述为: && || !
[ not ] like,用于模糊查询。 通配符: % 匹配多个字符; _ 匹配单个字符; 若须要真正的匹配%或者_须要在相应的符号前使用 反斜杠 \ ,或者也能够使用 escape 语句来指定某个字符做为转义字符。详细参见 Mysql refman-8.0-en.a4.pdf 第12.8节 P1939 。
mysql> SELECT 'David!' LIKE 'David\_';
-> 0
mysql> SELECT 'David_' LIKE 'David\_';
->1
mysql> SELECT 'David_' LIKE 'David|_' ESCAPE '|';
-> 1
[ not ] in (字段1,字段2 ...)**
例如: select * from where stu_id in (1,3,5); 筛选出学号为 1,3,5的学生的全部数据。
is [not] null 用于限定 字段值是否为空值NULL
( 注: '=' 只能用来判断普通内容 ; '<=>' 安全等于 :既能够判断普通内容也能够判断NULL值)。
分组筛选group by 与 分组后条件筛选having
查询结果排序呈现 **order by exp1 ASC/DESC [,exp2 ASC/DESC...] **
各语句之间的执行顺序:
from clause ——> where clause——>group by ** clause——>having** clause——>select clause
——>order by clause
杂
①. 查看警告信息: show warnings;
②. mysql8.0版本以上windows下支持命令清屏:system cls