还要说明一下,以上操作是使用的mysql数据库

解决方案 »

  1.   

    不支持,不过语句select substring(now(),1,7)是对的
    mysql> select substring(now(),1,7);
    +----------------------+
    | substring(now(),1,7) |
    +----------------------+
    | 2006-07              |
    +----------------------+
    1 row in set (0.06 sec)如果要实现你上面所说的功能,只能用程序另外做了,mysql是不支持这样做的,它支持默认值为now(),current_timestamp等函数,但是不支持再对这些函数进行操作作为默认值.
    mysql> create table t (id int not null auto_increment primary key,
        -> dd timestamp not null default now());
    Query OK, 0 rows affected (0.09 sec)
    mysql> insert into t(id) values(1);
    Query OK, 1 row affected (0.11 sec)
    mysql> select * from t;
    +----+---------------------+
    | id | dd                  |
    +----+---------------------+
    |  1 | 2006-07-18 09:47:27 |
    +----+---------------------+
    1 row in set (0.02 sec)