create table f_tablename
(
   id 
   recordtime           bigint not null default unix_timestamp(current_timestamp),
   primary key (id)
)
[Err] 1064 - You have an error in your SQL syntax; 上面的 recordtime 的缺省值处报语法错误,请大侠帮忙!

解决方案 »

  1.   

    CREATE TABLE f_tablename
    (
       id  INT,
       recordtime BIGINT NOT NULL DEFAULT 1,
       PRIMARY KEY (id)
    )
    DEFAULT中只能是常量
    The DEFAULT clause specifies a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. The exception is that you can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column. See Section 10.3.1.1, “TIMESTAMP Properties”. orCREATE TABLE f_tablename1
    (
       id  INT,
       recordtime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
       PRIMARY KEY (id)
    )
      

  2.   

    很不幸,目前的MYSQL在默认值中只支持常量。 (TIMESTAMP 字段除外)
    不能使用任何公式或者函数。
      

  3.   

    create table f_tablename
    (
      id  
      recordtime timestamp default now(),
      primary key (id)
    )
      

  4.   


    CREATE TABLE `FU_RecommendService` (
       `ServiceId` int(10) unsigned NOT NULL COMMENT '服务编号',
       `RecommendReason` varchar(256) COLLATE utf8_bin NOT NULL COMMENT '推荐理由',
       `CreatedDateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '推荐时间',
       PRIMARY KEY (`ServiceId`),
       KEY `IX_FU_RecommendService_CreatedDateTime` (`CreatedDateTime`)
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='推荐服务'
      

  5.   

    [SQL] EXPLAIN create table statusInfo
    (
       id                   int not null,
       billtype             int not null ,
       statuscode           int not null ,
       statusname           varchar(100) ,
       createtime           timestamp not null  ,
       isdisable            bit not null ,
       recordtime           timestamp not null ,
       primary key (id)
    )[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'create table statusInfo
    (
       id                   int not null,
       billtype  ' at line 1为什么老说是语法错误呢,mysql快整死人了
      

  6.   

    CREATE TABLE statusInfo
    (  id INT NOT NULL,
       billtype INT NOT NULL ,
       statuscode INT NOT NULL ,
       statusname VARCHAR(100) ,
       createtime TIMESTAMP NOT NULL ,
       isdisable BIT NOT NULL ,
       recordtime TIMESTAMP NOT NULL ,
       PRIMARY KEY (id)
    )
    测试没有问题
      

  7.   

    recordtime timestamp not null default CURRENT_TIMESTAMP ,上面的发错了,查了很多资料说是mysql的默认值只支持常量,不支持变量和函数!!甲骨文也不整的好用点……