ALTER TABLE a  ADD aId INT(10) UNSIGNED DEFAULT '-1' 
为什么不能通过???

解决方案 »

  1.   

    下面是成功的 
    ALTER TABLE a  ADD aId INT(10) DEFAULT '-1'否则总是失败
      

  2.   

    因为-1是有符号的,而你增加的这个列却被UNSIGNED 指定为无符号的,你知道为什么了吧。
    去掉UNSIGNED .
      

  3.   

     UNSIGNED是无符号的整型! 只能是正整数。
      

  4.   


    因为你从不看MYSQL的帮助文档。
      

  5.   

    http://dev.mysql.com/doc/refman/5.0/en/alter-table.htmlALTER TABLE t1 CHANGE a b INTEGER;If you want to change a column's type but not the name, CHANGE syntax still requires an old and new column name, even if they are the same. For example:ALTER TABLE t1 CHANGE b b BIGINT NOT NULL;You can also use MODIFY to change a column's type without renaming it:ALTER TABLE t1 MODIFY b BIGINT NOT NULL;When you use CHANGE or MODIFY, column_definition must include the data type and all attributes that should apply to the new column, other than index attributes such as PRIMARY KEY or UNIQUE. Attributes present in the original definition but not specified for the new definition are not carried forward. Suppose that a column col1 is defined as INT UNSIGNED DEFAULT 1 COMMENT 'my column' and you modify the column as follows:ALTER TABLE t1 MODIFY col1 BIGINT;The resulting column will be defined as BIGINT, but will not include the attributes UNSIGNED DEFAULT 1 COMMENT 'my column'. To retain them, the statement should be:ALTER TABLE t1 MODIFY col1 BIGINT UNSIGNED DEFAULT 1 COMMENT 'my co