文档章节

mysql基础知识

StayY
 StayY
发布于 2016/01/25 17:56
字数 472
阅读 8
收藏 0

1mysql存储结构: 数据库 -> -> 数据   sql语句

                    2)管理数据库:

                                            增加: create database 数据库 default character utf8;

                                            删除: drop database 数据库;

                                            修改: alter database 数据库 default character gbk;

                                            查询: show databases / show create database 数据库;

                    3) 管理表:      

                                             选择数据库:use 数据库;

                                             增加: create table (字段名1 字段类型,字段名2 字段类型......);

                                             删除: drop table ;

                                             修改:          

                                                             添加字段: alter table add [column] 字段名 字段类型;               

                                                             删除字段:   alter table drop [column] 字段名;

                                                             修改字段类型: alter table modify 字段名 新的字段类型;

                                                             修改字段名称 alter table change 旧字段名 新字段名 字段类型;

                                                    修改表名称:   alter table rename [to] 新表名;

                                            查询:

                                                             show tables  /  desc student;

                   4) 管理数据:

                                     增加: insert into (字段1,字段2,。。。) values(1,值2.。。。。);

                                     删除: delete from where 条件;

                                     修改: update set 字段1=1,字段2=2...... where 条件;

                                     查询:

                                                      4.1)所有字段: select * from ;

                                                      4.2)指定字段: select 字段1,字段2.... from ;

                                                      4.3)指定别名: select 字段1 as 别名 from ;

                         4.4 )合并列: select (字段1+字段2) from ;

                                                      4.5)去重: select distinct 字段 from ;

                                                      4.6)条件查询:

                                                                      a)逻辑条件 and()     or(或)

                                                                               select * from where 条件1 and/or 条件2

                                                                 b)比较条件: >  <  >=  <=  =  <>   between and(在。。。之间)

                                                                               select * from where servlet>=90;

                                                                      c)判空条件:

                                                                                判断null is null   /  is not null

                                                                               判断空字符串: =''    /  <>''

                                                                      d)模糊条件: like

                                                                                 %:  替换任意个字符

                                                                                 _:   替换一个字符                   

                                                     4.7 分页查询:limit 起始行,查询行数

                                                                      起始行从0开始

                                                     4.8 排序: order by 字段 asc/desc

                                                                      asc: 正序,顺序

                                                                      desc:反序,倒序

                                                     4.9 分组查询:group by 字段

                                                     4.10: 分组后筛选: having 条件

                                                    

                                   SQL语句的分类:                 

                                            DDL 数据定义语言

                                                             create / drop / alter     

                                            DML:数据操作语句

                                                             insert / delete /update / truncate        

                                            DQL 数据查询语言:

                                               select / show                  


© 著作权归作者所有

上一篇: mysql加强
StayY
粉丝 0
博文 38
码字总数 21515
作品 0
南昌
程序员
私信 提问

暂无文章

Redux

Redux概念 Redux = Reducer + Flux,数据层框架,将所有数据都存储到store中 Redux的工作流程 Antd的使用 安装npm install antd --save...

星闪海洋
45分钟前
2
0
OSChina 周一乱弹 —— 你们谁看见了我的诺贝尔奖

Osc乱弹歌单(2019)请戳(这里) 【今日歌曲】 @脚板薯 :这么晚不睡只为找到一首歌,晚安。 ♫Say You Want Me♪ ♫Say You Want Me♪ - Augustana 手机党少年们想听歌,请使劲儿戳(这里)...

小小编辑
55分钟前
169
14
我为什么要写微信公众号

埋一颗种子,细心呵护,静待她枝繁叶茂,葱郁参天 V2论坛上有个帖子【做程序员最重要的还是一定要有自己的作品】,作者写道: 能有一个作品和你的名字联系在一起,应当成为在职业生涯前期着意...

运维咖啡吧
今天
3
0
数据库

数据库架构 数据库架构可以分为存储文件系统和程序实例两大块,而程序实例根据不同的功能又可以分为如下小模块。 1550644570798 索引模块 常见的问题有: 为什么要使用索引 什么样的信息能成...

一只小青蛙
今天
5
0
PHP常用经典算法实现

<? //-------------------- // 基本数据结构算法 //-------------------- //二分查找(数组里查找某个元素) function bin_sch($array, $low, $high, $k){ if ( $low <= $high){ $mid = int......

半缘修道半缘君丶
昨天
6
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部