1、MySQL概要
关系型数据库。—Access数据库 oracle数据库、Postgresql-
非关系型数据库。—-Hbase等 库:—package 表:–class 字段:–属性 Oracle旗下产品—-分两种 (GPL协议的 社区版和企业版) CDH HDP–后面大数据给大家讲 Apache–hive hdfs hadoopRDBMS:关系数据库管理系统。将数据存储在不同的库表里面
支持标准的SQL语句100% 体积小 速度快 》MySQL Community Edition (GPL)-》MySQL OnWindows MySQL Installer-》Windows (x86, 32-bit), MSI Installer 8.0.13 313.8Mmysql-installer-community-8.0.13.0.msi
2、MySQL安装
DBA–数据库管理员
黑框框+workbench show databases;–展示所有库 show tables;–展示所有表; describe city;–展示表里面的字段信息 select * from city limit 10;3、Navicat安装与操作MySQL
Navicat Premium 是一套数据库开发工具,让你从单一应用程序中同时连接 MySQL、MariaDB、MongoDB、SQL Server、Oracle、PostgreSQL 和 SQLite 数据库。它与 Amazon RDS、Amazon Aurora、Amazon Redshift、Microsoft Azure、Oracle Cloud、MongoDB Atlas、
阿里云、腾讯云和华为云等云数据库兼容。你可以快速轻松地创建、管理和维护数据库更新数据库的密码
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘密码’;
4、MySQL数据类型
(1)数值类型
a、整型 tinyint 1个字节 smallint 2个字节 mediumint 3个字节 int 4 bigint 8 b、浮点型(float double) float(M,D) 小数位数部分会四舍五入。M=3 D=2 3.15 c、定点数 可变长度 decimal(M,D) M:表示总的有效位数,D表示小数的位数。3.14 3.145 (2)字符串类型 char:定长字符串 255个 varchar:变长字符串 varchar(25) 最大65535字符 blob:二进制字符串–文件 图片等 text:非二进制字符串–长文本。 (3) 日期数据类型 datetime:2018-12-22 21:04:55 timestamp:时间戳 2019021600000 ms5、MySQL外键、主键、唯一键
(1)外键 Foreign Key
如果换教室 302-303教室 需要对所有的数据进行 更新。30个学生 然后就得跟新30次。 (2) 主键 Primary Key 唯一不可重复 只能有一个主键,不能为null (3)唯一键 一个表可以有多个 唯一键 unique6、SQL语句–增删改查
SQL:Structure Query Language。—HiveQL Spark SQL
查询:
select字段(*) from 表明 (limit count) (where); 插入语句: insert into 表名 [字段名] values(值列表); 修改语句: update 表名 set 字段=值 where 条件; 删除语句: delete from 表名 [where 条件];例如:
SELECT * FROMclassroom
; insert into classroom VALUES(“001”,”9年级”,”11”,”CC”); update classroom SET classroom.classroomid=”0003” where classroom.classroomid=”001”; DELETE FROM classroom where classroom.classroomid=”0003”; TRUNCATE student;