mysql中count函数注意事项
表:
CREATE TABLE `user` (
`id` int(5) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT NULL,
`password` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
其中有数据为:
1 name1 123456
2 name2 123456
3 name3 123456
4 name4 NULL
以下三个查询返回几呢?
(1)select count(*) from `user`
(2)select count(name) from `user`
(3)select count(password) from `user`
答案是:4,4,3
因为:
(1)count(*)是对行数目进行计数,所以当然是4
(2)count(column_name)是对列中不为空的行进行计数,所以count(name)=4,而count(password)=3
相关文档:
====================================================
引自:http://blog.sina.com.cn/s/blog_538a9d1901008f9g.html
什么是C2级安全性?安全性的分类是怎样的?(2008-01-30 17:04:39)
D类:最低保护,保留给不能通过更高级别检查的系统
C1:谨慎保护,要求有基于用户级别的控制来保护数据,主要防� ......
我的系统是ubuntu6.06,最近新装好的mysql在进入mysql工具时,总是有错误提示:
# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
使用网上介绍的方法修改root用户的密码:
# mysqladmin -uroot -p password 'newpassword'
Enter pass ......
destroy-method="close">
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的优化不在行,搞过几次优化,但是都不是很理想,还是浪费资源太多。一直发现我的mysql的缓存命中率极差,情况良好的时候到达过60-70%,但是运行时间一长,只有10-20%。查了一些资料,关于缓存的一些参数记录
mysql> SHOW VARIABLES LIKE ‘%query_cache%’;
+—————&m ......