MySQL中表字段的操作

语法:

     alter table 表名 ...;

添加字段(add):

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

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

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

删除字段(drop):

   alter table 表名 drop 字段名;

修改字段数据类型(modify):

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

   会受到表中已有数据的限制

修改表名:

   alter table 表名 rename 新表名;

修改字段名:

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

表字段和表记录操作:

    表字段(alter table 表名)      表记录

    增   add                     insert into 表名 ...

    删   drop                    delete from 表名 ...

    改   modify                  update 表名 set  ...

    查   desc 表名                select * from 表名 ... 

猜你喜欢

转载自blog.csdn.net/weixin_43929852/article/details/86380548
今日推荐