日期:2014-05-18  浏览次数:20783 次

myaql数据库系统时间问题
以前用access数据库时,在设计表的时候直接在字段默认值一项里面填date()就能在添加新数据时自动保存系统时间,mysql能同样实现么??
那怎么实现呢?

------解决方案--------------------
Java code
java.text.SimpleDateFormat date = new java.text.SimpleDateFormat("MM/dd/yyyy, hh:mm:ss");


//"月/日/年, 时/分/秒"

String receivedTime = date.format(new Date(System.currentTimeMillis()));

------解决方案--------------------
SQL code
select now();
select current_date;
select sysdate();

------解决方案--------------------
建表的时候

youdate timestamp NOT NULL default CURRENT_TIMESTAMP

这样好象可以。