易截截图软件、单文件、免安装、纯绿色、仅160KB

mysql 中的 autocommit 变量

mysql> show variables like "autocommit";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit | ON |
+---------------+-------+
1 row in set (0.00 sec)
mysql>
设置完之后看看该值
你要开启一个事务,直接发送begin 。。。。commit就可以,何必要去动用这个参数。
mysql的后面版本一直不提倡修改这个参数。
postgresql甚至取消了这个参数,因为它认为事务控制应该由客户端来决定


相关文档:

MySQL小数位取整

//得分计算四舍五入
SELECT ROUND((SUM(getfeng)/SUM(totalfeng))*100) as feng from answerdata WHERE uid='151' AND targetid IS NOT NULL
1.ceil () /ceiling() 向上取整
   例: ceil(1.2) = 2
2.floor () 向下取整
    例: floor(1.2) = 1
3.round() 四舍五入
 &n ......

Mysql 复制表及结构

一、CREATE TABLE 方法
整表复制 # create table 新表 select * from 旧表;
结构复制 # create table 新表 select * from 旧表 where 1<>1;
二、INSERT INTO 方法
得到建表语句 # show create table 旧表;
新建表
复制数据到新表 INSERT INTO new_table(col1,col2,...) (SELECT col1,col2,... from old_table); ......

mysql中插入一条记录返回该记录id

1.select max(id) from user;
2.select last_insert_id() as id from user limit 1; 
(这个测试的返回id一直是0,有点问题)
3.储存过程
1)
oracel中
create sequence seqID
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
nocache
order;
create or replace procedure ......

mysql新增用户和登录


新增用户:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'你的远端ip' IDENTIFIED BY '你的密码' WITH GRANT OPTION;
如:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.10.19.220' IDENTIFIED BY '123456' WITH GRANT OPTION;
登录到新增的用户:(假如原授权机的IP为10.10.19.222)
mysql -uroot  -p123456&n ......

使用mysql中的with rollup得到group by的汇总信息

使用mysql中的with rollup可以得到每个分组的汇总级别的数据:
表如下:
CREATE TABLE `test3` (
  `id` int(5) unsigned NOT NULL AUTO_INCREMENT,
  `name1` varchar(10) DEFAULT NULL,
  `name2` varchar(10) DEFAULT NULL,
  `cnt` int(2) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGI ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号