zoukankan      html  css  js  c++  java
  • 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 表名

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

    心有多大,天有多高,一起奋斗!!
  • 相关阅读:
    寻找完全数(C++)
    莱布尼兹三角形(C++)
    简单的素数问题(C++)
    ubuntu17.04下安装LNMP
    ubuntu下连接mysql出现Access denied for user 'rose'@'localhost' (using password: NO)的解决方法
    快速理解面向对象的PHP编程--基础篇
    百度电面总结
    操作系统基础知识
    快速理解C语言指针
    新手学习MongoDB的基本命令
  • 原文地址:https://www.cnblogs.com/zhaolei1996/p/12348560.html
Copyright © 2011-2022 走看看