Q1、
mysql> create table reservation(
    -> ordernum int not null auto_increment,
    -> fid int references flight,
    -> cid int references customer,
    -> qty int,
    -> orderdate date default now(),
    -> cardnum char(20) references card,
    -> primary key(ordernum)
    -> );
ERROR 1067 (42000): Invalid default value for 'orderdate'Q2、
mysql> create table flight(
    -> fid int not null default '000000' auto_increme
    -> fnumber char(20) not null,
    -> fdate date,
    -> ftime datetime,
    -> price double default '0.00',
    -> capacity int,
    -> dest int references airport,
    -> orig int references airport,
    -> primary key(fid)
    -> );
ERROR 1067 (42000): Invalid default value for 'fid'

解决方案 »

  1.   

        -> fid int not null default '000000' auto_incremet在增长的字段不要放default了
    == 思想重于技巧 ==
      

  2.   

     mysql> create table flight( 
         -> fid int not null auto_incremet
         -> fnumber char(20) not null, 即可,自然会从1开始, 000001 
     000002 
    你可以在显示中处理
    == 思想重于技巧 ==
      

  3.   

    sigh, 你要的是下边的效果吧,照着我的改吧。没有default, 只有int(宽度) 和 zerofillmysql> create table t3(fid int(6) zerofill not null auto_increment primary key);Query OK, 0 rows affected (0.19 sec)mysql> insert into t3 values(null);
    Query OK, 1 row affected (0.11 sec)mysql> select * from t3;
    +--------+
    | fid    |
    +--------+
    | 000001 |
    +--------+
    1 row in set (0.08 sec)
      

  4.   

     -> orderdate date default now(),那这句怎么办啊?
    我想把订单时间设置为当前时间:
      

  5.   

    回 iihero,
    我怎么就没想到zerofill 呢?呵呵
    总想着用default!
      

  6.   

    我想把订单时间设置为当前时间:
     -> orderdate date default now(),
      

  7.   

    CURDATE() 
    == 思想重于技巧 ==
      

  8.   

    回liuyann:
    我试了 ,不行
    create table reservation(
    ordernum int not null auto_increment,
    fid int references flight,
    cid int references customer,
    qty int,
    orderdate date CURDATE(),
    cardnum char(20) references card,
    primary key(ordernum)
    );
      

  9.   

    orderdate date default now
    这个恐怕不能如愿了。似乎mysql并不支持now()函数或者curdate()函数作为default的计算值。其实你压根不用为此担心啊。
    mysql> create table t3(id int, t date);
    Query OK, 0 rows affected (0.11 sec)mysql> insert into t3 values(1, now());
    Query OK, 1 row affected (0.09 sec)mysql> select * from t3;
    +------+------------+
    | id   | t          |
    +------+------------+
    |    1 | 2008-03-29 |
    +------+------------+
    1 row in set (0.01 sec)无非是多写了一个字段插入now()