MySQL数据库的概念介绍

发布时间:2021-08-30 19:12:41 作者:chen
来源:亿速云 阅读:210

本篇内容主要讲解“MySQL数据库的概念介绍”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“MySQL数据库的概念介绍”吧!

1.数据库概念
2.常用的数据库分类

MySQL数据库的概念介绍

3.关系型数据库的优缺点

优点:

缺点:

4.非关系型数据库的优缺点

优点:

缺点:

5.MySQL数据库的概念

MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行的开源数据库,因此被广泛地应用在Internet上的中小型网站中。随着MySQL的不断成熟,它也逐渐用于更多大规模网站和应用,比如维基百科、Google和Facebook等网站。非常流行的开源软件组合LAMP中的“M”指的就是MySQL;

6.MySQL数据类型
7.SQL语句分类
# 创建库
create database Student;
# 如果没有Student这个库则创建它,character set指定字符集为utf8, 排序规则为utf8_bin
create datebase if not exists Student character set utf8 collate utf8_bin
# 删除库
drop database Student;
# 修改库
alter database Student character set = utf8mb4
alter database Student collate = utf8mb4_general_ci
# 创建表
create table students (id int not null primary key auto_increment, name varchar(250) not null, class varchar(250) not null) engine=InnoDB default charset=utf8;
# 查看表结构
desc students;
# 修改表
alter table students add gender enum('f','m');
alter table students drop gender;
alter table students change name username varchar(100) after id;
alter table students modify username varchar(100) first;
# 删除表
drop table students;
# 给students表增加数据
insert into students (class,username) values ('一年级', 'Luky'), ('二年级', 'Tom'), ('三年级', 'Mark');
# 修改students表中id = 1 的字段class的值为“初一”
update students set class = '初一' where id = 1;
# 删除class为一年级的字段
delete from students where class = '一年级';
# 先创建用户,再授权
create user Mark@'172.16.19.%' identified by '123456';
grant all on *.* to Mark@'172.16.19.%';
flush privileges;
# 创建用户的同时给用户授权
grant all on *.* to Mark@'172.16.19.%' identified by '123456';
flush privileges;
# 给用户授予某些权限
show grants for Mark@'172.16.19.%';
# 撤销授权
revoke select ON *.* from Mark@'172.16.19.%';
flush privileges;
# 查看用户的权限
show grants for Mark@'172.16.19.%';
# 删除用户
delete from mysql.user where user = "Mark";
flush privileges;
# 删除用户
drop user 'Mark'@'192.168.%.%';
# 修改密码
(1)set password for 'Mark'@'192.168.%.%' = password('123456');
(2)使用update命令,直接修改 mysql.user 用户表,修改之后flush priveleges;
# SQL删除记录语句
sql = "DELETE FROM Student WHERE AGE > %s" % (30)
try:
    cursor.execute(sql)
    # 向数据库提交
    db.commit()
except:
    # 发生错误时回滚
    db.rollback()
8.SELECT 语句

MySQL数据库的概念介绍

select * from Student
select id,name from Student;
select id as num,name from Student;
select id as num,name as username from Student;
select * from Student where id >= 1;
select * from Student where id <= 5 and id >1;
select * from Student where id <3 or id >10;
select * from Student where id between 1 and 5;    # between 较小的数 and 较大的数
select * from Student where class like 'Ma%';
select * from Student where class like 'Ma_k';
select * from Student where id is not null;
select * from Student where id is null;
select age,gender from students group by gender; 
select avg(age),gender from students group by gender; 
select min(age), gender from students group by gender;
select max(age), gender from students group by gender;
select count(id), gender from students group by gender;
select * from Student order by id desc;
select avg(age) as 'average_age', gender from students group by gender having average_age > 50;
# 选前5行
select id,name from students order by id desc limit 5; 
# 前4个不选,从第5行开始选2行
select id,name from students order by id limit 4, 2;
select *,avg(score) as '各班平均成绩' from students where id > 1 group by class having avg(score) > 55 order by score desc limit 3 ;

到此,相信大家对“MySQL数据库的概念介绍”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

推荐阅读:
  1. Ceph概念介绍及组件介绍
  2. HDFS的基本概念介绍

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mysql 数据库

上一篇:有关Ajax跨域问题的解决方法

下一篇:Python中Mysqldb和webpy的安装方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》