没有合适的资源?快使用搜索试试~ 我知道了~
数据库迁移为MYSQL的总结。 注意事项和代码。
资源推荐
资源详情
资源评论
@@IDENTITY 改写为: Last_Insert_ID();
关键字用做字段用 `关键字` 扩起来 ~ 键那边
isnull(exp1,exp2) -> ifnull(exp1,exp2)
getdate() -> now()
show databases; -- 显示所有数据库
use 数据库名 -- 进入数据库
show tables; -- 显示表
show columns from 表名 -- 显示表中字段
desc 表名 -- 显示表中字段
-- 注释内容 --与注释之间要有空格
每条sql语句后加 ; 号
SQL语句不区分大小写
distinct -- 不重复行 eg. select distinct groupname from table;
limit -- 分页:第1行为0
eg. select * from users limit 5;
eg. select * from users limit 10,5; 从第10行开始取5行
eg. select * from users limit 10 offset 5 从第10行开始取5行,写法不同而已
<> != -- 不等于 两符号相同作用
is null eg. select * from users where uname is null;
regexp -- 正则匹配 eg. select uname from users where user regexp 'li' order by uname;
\\ -- 正则:转义符用\\ eg. \\.
[:alnum:] 任意字母和数字 = [a-zA-Z0-9]
[:alpha:] 任意字符 = [a-zA-Z]
[:blank:] 空格和制表 = [\\t]
[:lower:] 任意小写字母 = [a-z]
[:upper:] 任意小写字母 = [A-Z]
[:digit:] 任意数字 = [0-9]
[:space:] 任意空白字符 =[\\f\\n\\r\\t\\v]
select convert('2010-01-01',datetime)>now() -- 字符串转时间
关键字用做字段用 `关键字` 扩起来 ~ 键那边
isnull(exp1,exp2) -> ifnull(exp1,exp2)
getdate() -> now()
show databases; -- 显示所有数据库
use 数据库名 -- 进入数据库
show tables; -- 显示表
show columns from 表名 -- 显示表中字段
desc 表名 -- 显示表中字段
-- 注释内容 --与注释之间要有空格
每条sql语句后加 ; 号
SQL语句不区分大小写
distinct -- 不重复行 eg. select distinct groupname from table;
limit -- 分页:第1行为0
eg. select * from users limit 5;
eg. select * from users limit 10,5; 从第10行开始取5行
eg. select * from users limit 10 offset 5 从第10行开始取5行,写法不同而已
<> != -- 不等于 两符号相同作用
is null eg. select * from users where uname is null;
regexp -- 正则匹配 eg. select uname from users where user regexp 'li' order by uname;
\\ -- 正则:转义符用\\ eg. \\.
[:alnum:] 任意字母和数字 = [a-zA-Z0-9]
[:alpha:] 任意字符 = [a-zA-Z]
[:blank:] 空格和制表 = [\\t]
[:lower:] 任意小写字母 = [a-z]
[:upper:] 任意小写字母 = [A-Z]
[:digit:] 任意数字 = [0-9]
[:space:] 任意空白字符 =[\\f\\n\\r\\t\\v]
select convert('2010-01-01',datetime)>now() -- 字符串转时间
Concat() -- 拼接串 eg. select concat(uname,'(',counry,')') from users;
显示为:
Contat(uname,'(',counry,')')
------------------------------------------
Lisi(China)
Ann(USA)
RTrim(字符串) 去右边空格
LTrim(字符串) 去左边空格
Trim(字符串) 去两边空格
as -- 将列明更换 eg. select uname as PersonName from users;
Upper(字符串) -- 变大写
Lower() -- 变小写
Left() -- 返回左边的字符
Right() -- 返回右边的字符
Length() -- 返回串长度
Locate() -- 展出串的一个子串
SubString() -- 返回子串的字符
Soundex() -- 返回串的soundex值,匹配所有发音类似的字段
eg. select uname,contact from users where Soundex(uname)=Soundex('Y Lie')
显示 uname contact
---------------------------
Y Lee 110
UNIX_TIMESTAMP(NOW())- UNIX_TIMESTAMP(BuyerEndTime) -- 两个时间相差多少秒
eg. SELECT "1998-01-01" - INTERVAL 120 SECOND; -- 增加或减少时间
AddDate() 增加一个日期(天、周等)
剩余13页未读,继续阅读
资源评论
91李
- 粉丝: 4
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功