mysql数据库表的管理(增删改)

表字段管理

    1. 添加到末尾

    alter table 表名 add 字段名 数据类型;

    

    2 添加到开头

    alter table  表名 add 数据类型 first;

    

    3. 添加到指定位置

    alter table 表名 add 新字段名 数据类型 after 原有字段名;

    

    4. 删除字段

    alter table 表名 drop 字段名;

    

    5. 修改数据类型

    alter table 表名 modify 字段名 新数据类型;

    

    6. 修改字段名

    alter table 表名 change 旧名 新名 数据类型;

    

    7. 修改表名:

    alter table 表名 rename 新表名;


表记录管理

    1. 更新表记录

    update 表名 set 字段名=值1,字段名=值2,...;

    

    2. 删除表记录

    delete from 表名 where=条件;

    delete必须加where条件,否则将会删除所有记录


猜你喜欢

转载自blog.51cto.com/calabash/2143810