热门文章
/***MySQL语句学习总结*Author:bdzsl2013*/~~~~~~~数据库操作~~~~~~~1、查看数据库showdatabases;2、选择数据库usedbname;3、创建数据库createdatabasedbname;4、删除数据库dropdatabasedbname;~~~~~~~~~表操作~~~~~~~~~1、创建表createtabletbname(col1type1[notnull][primarykey],col2type2,...colntypen);2、查看表结构describetbname;3、删除表droptabletbname;4、修改表名altertabletbnamerenamenewname;5、增加列altertabletbnameaddcolumncolnamecoltype;Tips:列增加后将不能删除6、删除列altertabletbnamedropcolumncolname;7、修改列信息altertabletbnamechangecolumncolnamenametype;~~~~~~~~~基本mysql语句~~~~~~~~~1、选择select*fromtbnamewhereconstrainment(约束条件)2、插入insertintotbname(field1,field2)values(value1,value2);3、删除deletefromtbnamewhereconstrainment(约束条件)4、更新updatetbnamesetfield1=value1whereconstrainment(约束条件)5、查找select*fromtbnamewherefield1like'%value%';(like语法)6、排序select*fromtbnameorderbyfield1,field2[desc];7、总数selectcount(field1)astotalcountfromtbname;8、求和selectsum(field1)assumvaluefromtbname;9、平均selectavg(field1)asavgvaluefromtbname;10、最大selectmax(field1)asmaxonefromtbname;11、最小selectmin(field1)asminonefromtbname;
“常用的SQL语句有哪些”的内容就介绍到这里了,感谢大家的阅读。