mysql常用语句

一、对数据行的增删改查

增:insert   into   tableName ()   values(),()            可以一次插入多条或者一条,前面可以指定插入的字段,不指定的话默认为建表时的顺序

删:delete from tableName where....

改:update tableName set 字段名=.... where ...

查:select ,,, from table .......                  查询的类型比较多 子查询 联合查询    与where的组合使用

二、对数据库字段的增删改

增:alter table tableName  add column 字段名  类型  ....               后面部分和建表时是一样的

删:alter table tableName drop 字段名

改:alter table tableName modify column 字段名 类型....

三、建表与删除表

建表:create table tableName(

字段名   类型   其他属性(是否非空  编码类型  是否自增   )

)

删除表:drop  table  tableName;

四、创建索引与删除索引、查询索引

创建索引:create index  索引名称  on  表名 (索引字段)  可对表增加普通索引或UNIQUE索引

      alter  table  tableName add index  索引名称 (字段)  可对表增加普通索引或UNIQUE索引和primary 索引

     在创建表时指定 key 索引名 (字段)  可对表增加普通索引或UNIQUE索引和primary 索引

删除索引:drop index  索引名 on table

     alter table 表名 drop index  索引名

查询索引:show keys from 表名

     show  indexs from 表名

没有提供有直接修改索引的语句

心有多大,天有多高,一起奋斗!!
原文地址:https://www.cnblogs.com/zhaolei1996/p/12348560.html