例如 姓名 年龄 地址  
     老李  35   XXX 
      .     .    .
      .     .    .
      .     .    .添加一个列  姓名 年龄 地址  是否有房
             .    .    .     未知 
             .    .    .       .         
             .    .    .       .添加的这个列名 是否有房 下面的内容全部都是未知 如何 添加 谢谢各位了

解决方案 »

  1.   

    mysql> select * from t_hiphopthehook;
    +-----------------+------+
    | 身份证          | 姓名 |
    +-----------------+------+
    |    435435465546 | WW   |
    | 432432452454645 | SS   |
    |  54356356654542 | AA   |
    +-----------------+------+
    3 rows in set (0.00 sec)mysql> alter table t_hiphopthehook add 是否有房 varchar(10) default '未知';
    Query OK, 3 rows affected (0.13 sec)
    Records: 3  Duplicates: 0  Warnings: 0mysql> select * from t_hiphopthehook;
    +-----------------+------+----------+
    | 身份证          | 姓名 | 是否有房 |
    +-----------------+------+----------+
    |    435435465546 | WW   | 未知     |
    | 432432452454645 | SS   | 未知     |
    |  54356356654542 | AA   | 未知     |
    +-----------------+------+----------+
    3 rows in set (0.00 sec)mysql>
      

  2.   

    或者你也可以不用这个default alter table t_hiphopthehook add 是否有房 varchar(10);
    然后再执行
    update t_hiphopthehook  set 是否有房='未知';
      

  3.   

    mysql> alter table t_hiphopthehook add 是否有房 varchar(10) default '未知';
    Query OK, 3 rows affected (0.13 sec)
    Records: 3  Duplicates: 0  Warnings: 0
    这个最经典
      

  4.   

    删除一列 包括它的field也删除 该如何处理?
      

  5.   

    mysql> select * from t_hiphopthehook;
    +-----------------+------+----------+
    | 身份证          | 姓名 | 是否有房 |
    +-----------------+------+----------+
    |    435435465546 | WW   | 未知     |
    | 432432452454645 | SS   | 未知     |
    |  54356356654542 | AA   | 未知     |
    +-----------------+------+----------+
    3 rows in set (0.00 sec)mysql> alter table t_hiphopthehook drop 姓名;
    Query OK, 3 rows affected (0.20 sec)
    Records: 3  Duplicates: 0  Warnings: 0mysql> select * from t_hiphopthehook;
    +-----------------+----------+
    | 身份证          | 是否有房 |
    +-----------------+----------+
    |    435435465546 | 未知     |
    | 432432452454645 | 未知     |
    |  54356356654542 | 未知     |
    +-----------------+----------+
    3 rows in set (0.01 sec)mysql>
      

  6.   

    建议楼主能自己看一下帮助文档。13.1.2. ALTER TABLE语法
    http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html#alter-table
      

  7.   

    mysql> alter table t_hiphopthehook drop 姓名;
    Query OK, 3 rows affected (0.20 sec)
    Records: 3  Duplicates: 0  Warnings: 0
      

  8.   

    增加列:alter table tb_name add 列名 类型
    删除列:
    alter table tb_name drop 列名更改列:
    alter table tb_name modify 列名 类型...