这两天在思考怎么生成数据库随机名称,思前想后觉得还是利用自增的逻辑主键是最方便快捷的,于是便尝试着获取一种自增的mysql函数 自增mysql函数 BEGIN DECLARE id INT DEFAULT ; SELECT cuid + INTO id from uc_gen_number where table_key = tableKey for update; IF id = THEN SET id = ; INSERT INTO uc_gen_number (table_key, cui
每次设置root和远程访问都容易出现问题, 总结了个通用方法, 关键在于实用 step1: # mysql -u root mysql mysql> Grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option; //增加远程访问权限mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’; //增加ro
一.sql中使用正则表达式 select name,email from user where email Regexp "@163[.,]com$"; sql语句中使用Regexp对性能影响较大. 二.使用Rand()函数获取随机数据 rand();随机数函数 1.随机排序 mysql> select * from hello order by rand(); 2.随机列抽取3条 mysql> select * from hello order by rand() lim