很多时候,我们建立数据库的时候需要指定一个id为自动增长的主键,同时写入当前时间。
我们可以通过设定数据类型来达到这个目的。
CREATE TABLE TableName ( Id int auto_increment primary key not null, //设定一个自动增长的主键 Resquest varchar(500), Response varchar(1000), Time timestamp //设定类型为时间戳,会写入当前时间 );
向表中插入数据的时候,只需要插入Resquest和Response就可以了,数据库会写入自动增长的id以及时间。
INSERT INTO TableName ( Resquest, Response ) VALUES ( '$resquest', '$response' )
这篇文章还没有人留言,快来抢沙发吧。