mysql数据库基本操作语句

1 更改字段名:change

    alter table student change column gradenews grade int(11);

2 增加字段和删除字段

   alter table  student add column salary int(30) default 900000;

   alter table student drop column salary;

   ALTER TABLE student ADD COLUMN ages  VARCHAR(20) NOT NULL;

   alter table student drop column ages

3 修改字段的长度:modify

  alter table student modify id int(20);

  

4 批量增加字段

alter table student add (age1 varchar(20), ids int(17), num int(34) default 7546123);

或者使用事务的方式:事务需要commit;

5 批量修改字段的名称:change

alter table student change s11 s111 int(7), change s12 s112 int(8) default 2019;

6 查询某年级的人数

select count(1) from student where grade = 5;

select count(*) from student where grade = 5;

猜你喜欢

转载自www.cnblogs.com/guofen3399/p/11831350.html