在MYSQL 命令行下运行 select table_name from information_schema.columns where EXTRA='on update CURRENT_TIMESTAMP'; 有无结果
很少命令行下执行。 怎么select 都没反应的。 :(
进入MYSQL的命令行没有? 有无类似如下的显示 mysql> select table_name -> from information_schema.columns -> where EXTRA='on update CURRENT_TIMESTAMP';
Enter password: ***** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 98 Server version: 5.0.41-community-nt MySQL Community Edition (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> select table_name from information_schema.columns where EXTRA='on update CURRENT_TIMESTAMP' ->
仔细看看我的代码,少了一个; mysql> select table_name -> from information_schema.columns -> where EXTRA='on update CURRENT_TIMESTAMP';
mysql> select table_name from information_schema.columns where EXTRA='on update CURRENT_TIMESTAMP'; Empty set (0.48 sec)mysql>
示例: CREATE TABLE `week_click` ( `id` mediumint(8) unsigned zerofill NOT NULL AUTO_INCREMENT, `ware_id` mediumint(9) DEFAULT NULL, `click_count` mediumint(9) NOT NULL, `addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8建立这个 表,再用上述语句检查一下,应该有结果,比如`addtime`的EXTRA 为 on update CURRENT_TIMESTAMP
你上面sql addtime 是有ON UPDATE CURRENT_TIMESTAMP的了。 但`addtime`的EXTRA 没有 on update CURRENT_TIMESTAMP的。
mysql> CREATE TABLE `week_click` ( -> `id` mediumint(8) unsigned zerofill NOT NULL AUTO_INCREMENT, -> `ware_id` mediumint(9) DEFAULT NULL, -> `click_count` mediumint(9) NOT NULL, -> `addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURREN T_TIMESTAMP, -> PRIMARY KEY (`id`) -> ) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; Query OK, 0 rows affected (0.05 sec)mysql> select table_name from information_schema.columns where EXTRA='on update '> CURRENT_TIMESTAMP'; Empty set (0.44 sec)mysql>
估计是版本问题,我的版本是5.1.32 只有查询 建立表的语句是否有 on update CURRENT_TIMESTAMP
应该是版本问题了。 只能show create table 分析sql语句了 我看phpmyadmin的代码也是分析sql处理了的。还有随便问个问题。 一个表有索引 查询 SELECT COUNT(id) FROM `post` 服务器上 linux / MySQL client version: 5.0.45 运行只要0.000023 秒而在我本地xp / MySQL 端: 5.0.37 就要2多秒 这是怎么会事。 表与数据都一模一样的。
在XP上连接服务器上的MYSQL再运行,还是在XP机器上安装MYSQL,再运行?
本地查询本地的mysql。没查网络。就查本地的表。本地与服务器都装有mysql 各自查询各自的。
索引情况是否一致,SQL语句是什么 EXPLAIN SQL语句
就这SQL。 SELECT COUNT( `post_id` ) FROM `post` --------------------- 状态 时间(initialization) 0.00003775 Opening tables 0.00000925 System lock 0.00002050 Table lock 0.00000750 init 0.00001550 optimizing 0.00000750 statistics 0.00001050 preparing 0.00000800 executing 0.00000475 Sending data 5.33135850 end 0.00000975 query end 0.00000575 freeing items 0.00001000 closing tables 0.00000650 logging slow query 0.00000325结果 ---------------------- COUNT( `post_id` ) 117900EXPLAIN id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE post index NULL PRIMARY 4 NULL 141079 Using inde好吃力啊 好吃力啊 好吃力啊
得到建表语句,然后直接分析即可。
因为注释 字段 什么都可以写 on update CURRENT_TIMESTAMP 这些字符串。
from information_schema.columns
where EXTRA='on update CURRENT_TIMESTAMP'
%..% 一样。没消息。
..........
其它表也没有的。
-> from information_schema.columns
-> where EXTRA='on update CURRENT_TIMESTAMP';
+--------------+
| table_name |
+--------------+
| points |
| week_click |
| columns_priv |
| event |
| general_log |
| proc |
| procs_priv |
| slow_log |
| tables_priv |
| ttl2 |
+--------------+
10 rows in set (0.11 sec)mysql>
select table_name from information_schema.columns where EXTRA='on update CURRENT_TIMESTAMP';
有无结果
怎么select 都没反应的。
:(
有无类似如下的显示
mysql> select table_name
-> from information_schema.columns
-> where EXTRA='on update CURRENT_TIMESTAMP';
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 98
Server version: 5.0.41-community-nt MySQL Community Edition (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> select table_name from information_schema.columns where EXTRA='on update
CURRENT_TIMESTAMP'
->
mysql> select table_name
-> from information_schema.columns
-> where EXTRA='on update CURRENT_TIMESTAMP';
mysql> select table_name from information_schema.columns where EXTRA='on update
CURRENT_TIMESTAMP';
Empty set (0.48 sec)mysql>
CREATE TABLE `week_click` (
`id` mediumint(8) unsigned zerofill NOT NULL AUTO_INCREMENT,
`ware_id` mediumint(9) DEFAULT NULL,
`click_count` mediumint(9) NOT NULL,
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8建立这个 表,再用上述语句检查一下,应该有结果,比如`addtime`的EXTRA 为 on update CURRENT_TIMESTAMP
但`addtime`的EXTRA 没有 on update CURRENT_TIMESTAMP的。
mysql> CREATE TABLE `week_click` (
-> `id` mediumint(8) unsigned zerofill NOT NULL AUTO_INCREMENT,
-> `ware_id` mediumint(9) DEFAULT NULL,
-> `click_count` mediumint(9) NOT NULL,
-> `addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURREN
T_TIMESTAMP,
-> PRIMARY KEY (`id`)
-> ) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.05 sec)mysql> select table_name from information_schema.columns where EXTRA='on update
'> CURRENT_TIMESTAMP';
Empty set (0.44 sec)mysql>
只有查询 建立表的语句是否有
on update CURRENT_TIMESTAMP
只能show create table 分析sql语句了
我看phpmyadmin的代码也是分析sql处理了的。还有随便问个问题。
一个表有索引
查询 SELECT COUNT(id) FROM `post`
服务器上 linux / MySQL client version: 5.0.45
运行只要0.000023 秒而在我本地xp / MySQL 端: 5.0.37
就要2多秒
这是怎么会事。
表与数据都一模一样的。
EXPLAIN SQL语句
SELECT COUNT( `post_id` ) FROM `post`
---------------------
状态 时间(initialization) 0.00003775
Opening tables 0.00000925
System lock 0.00002050
Table lock 0.00000750
init 0.00001550
optimizing 0.00000750
statistics 0.00001050
preparing 0.00000800
executing 0.00000475
Sending data 5.33135850
end 0.00000975
query end 0.00000575
freeing items 0.00001000
closing tables 0.00000650
logging slow query 0.00000325结果 ----------------------
COUNT( `post_id` )
117900EXPLAIN id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE post index NULL PRIMARY 4 NULL 141079 Using inde好吃力啊 好吃力啊 好吃力啊
本地表是InnoDB类型的。差别这么大啊。
只能这样了?都有PRIMARY的啊。也就是索引了吧。
117900条记录count一下用5.33135850有点.................
MYISAM的读速度比INNODB的快,写比INNODB的慢
估计是这个原因,一般本地读取速度>网络读取速度