日期:2014-05-16 浏览次数:20713 次
--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该怎么写呢 */
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: 0 mysql> insert into msgs values(null, 'abc', 'a@a.com', 'no content', null); Query OK, 1 row affected (0.03 sec)