mysql复制表结构有很多方法,其中最好用的要算是:create table newtable like oldtable
除此之外还有很多办法,如果用工具的话。当然是非常方便。。比如用navicat的时候,直接选中,复制粘贴就是一个新表。然后再Truncate table newtable就完事了
除此之外还有一些命令行:
1、create table newtable select * from oldtable ,这个和上面说的用navicat工具一样。复制完后还得truncate table
2、show create table oldtable ;这个会将原表的所有结构导出,不过,问题在于,表名要修改,itoa(递增的ID)要修改
3、mysqldump ,这个就不用说了。。。没啥意思。。。出来之后还得象第二步一样操作
所以,还是用create table newtable like oldtable。。。
在博客园看到有人在介绍CoffeeScript,以前仿佛看过类似的东西。所以去官方看了一下,结果发现现在的代码是不是都在追求所谓的语义化?
比如你看这一段 :
mood = greatlyImproved if singing if happy and knowsIt clapsHands() chaChaCha() else showIt() date = if friday then sue else jill options or= defaults
然后所谓生成后的代码就成了这样:
var date, mood; if (singing) mood = greatlyImproved; if (happy && knowsIt) { clapsHands(); chaChaCha(); } else { showIt(); } date = friday ? sue : jill; options || (options = defaults);
看到上面的这段生成后的代码,再对比一下原来的写法,是不是觉得很有意思?
再来一段长的:
grade = (student) -> if student.excellentWork "A+" else if student.okayStuff if student.triedHard then "B" else "B-" else "C" eldest = if 24 > 21 then "Liz" else "Ike"
输出之后就是:
var eldest, grade; grade = function(student) { if (student.excellentWork) { return "A+"; } else if (student.okayStuff) { if (student.triedHard) { return "B"; } else { return "B-"; } } else { return "C"; } }; eldest = 24 > 21 ? "Liz" : "Ike";
越来越发现,原来写伪代码也可以转换成代码。而且看上去也不错,有点象zen coding了。现在很多IDE都支持zen coding
不知道这次这个coffeescript什么时候会被支持
官网:http://jashkenas.github.com/coffee-script/
但是对于用户来说,有一点压力,因为它还是会有一些学习成本。