读书人

高手热心人来看看,该如何处理

发布时间: 2012-02-19 19:43:38 作者: rapoo

高手热心人来看看
-- 这条SQL为什么运行不了?错误好像是1064
-- MYSQL 5.1, WinXP

SQL code
--use dbtest;create table msgs( msgid int auto_crement not null, title varchar(20) not null, email varchar(40), msgtext text not null, primary key(msgid));/* * 另外我想问下, 如果我想在表中添加一个msgtime, 此字段根据消息生成的系统时间而生成, 这个sql该怎么写? * 又如果把它存储成字符串20120112185530那SQL该怎么写呢*/ 


[解决办法]
SQL code
mysql> create table msgs(    ->  msgid int [color=#FF0000]auto_increment[/color] not null,    ->  title varchar(20) not null,    ->  email varchar(40),    ->  msgtext text not null,    ->  primary key(msgid)    -> );Query OK, 0 rows affected (0.08 sec)mysql> alter table msgs add msgtime timestamp DEFAULT CURRENT_TIMESTAMP;Query OK, 0 rows affected (0.28 sec)Records: 0  Duplicates: 0  Warnings: 0mysql> insert into msgs values(null, 'abc', 'a@a.com', 'no content', null);Query OK, 1 row affected (0.03 sec) 

读书人网 >Mysql

热点推荐