mysql 建表语句

时间:2023-01-06 16:29:28

修改id为自动增长: alter table book b_ISBN int(11) auto_increment;

  自动增长要加的:auto_increment

基本的sql语句:

  1. 选择:select * from table where 范围

  2.  插入:insert into table(field1,field2) values(value1,value2)
  3.  删除:delete from table where 范围
  4.  更新:update table set field1=value1 where 范围
  5.  查找:select * from table where field1 like ’%value1%’
  6.  排序:select * from table order by field1,field2 [desc]
  7. 修改id为自动增长 alter table book b_ISBN int(11) auto_increment
  8. 总数:select count as totalcount from table
  9. 求和:select sum(field1) as sumvalue from table
  10. 平均:select avg(field1) as avgvalue from table
  11. 最大:select max(field1) as maxvalue from table
  12. 最小:select min(field1) as minvalue from table