-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysql
35 lines (28 loc) · 1.02 KB
/
mysql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
1.创建用户
创建本地用户: create user 'username'@'localhost' identified by 'password';
创建远程用户: create user 'username'@'ip/network' identified by 'password';
2.显示当前时间,用户,版本: select now(), user(), version();
3.创建数据库 : create database dbname;
4.显示当前使用的数据库: select database();
5.插入数据:
insert into tablename values(),()
insert into tablename set xx=xx, xx=xx
load data locale infile 'filename' into table tablename;
6.重设数据库 : source filename.sql
7.赋予权限: grant all on mysqldb.* to 'samuel'@'localhost';
8.where子句里的表达式允许算术,比较,逻辑表达式,还允许使用括号
算术:+,-,*,/,DIV,%
逻辑:and,or,xor,not
比较:<=,<,>,>=,<=>,!=,<>
9.order by 默认为升序排序
order by xx asc 升序
order by xx desc 降序
10.limit
limit 5 返回5个数据
limit 10,5 返回第10个数据之后的5个数据
11.匹配模式
like
not like
>>>>>>>>>>
_ : 匹配单个字符
% : 匹配任意个字符,包括空字符