SQL基础知识

1.关系型数据库的特点

理论基础:关系代数(集合论、一阶逻辑、关系运算)
具体表象:用二维表装数据

​ - 表 - table / entity - relation
​ - 列 - column / field - attribute
​ - 行 - row / record - tuple
​ - 列的数量 - deg ree
​ - 行的数量 - cardinality
​ - 主键 - primary key
​ - 外键 - foreign key

​ 编程语言:结构化查询语言(SQL)

2.SQL

DDL(数据定义语言)- create / drop / alter

create database / drop database
create table / drop table / alter table

- add column / drop column
- modify column / change column
- add constraint / drop constraint

primary key
foreign key
check
unique

- rename to

DML(数据操作语言)- insert / delete / update / select
DCL(数据控制语言)- grant to / revoke from

3.MySQL命令

show databases;
show tables;
show engine;
show character set;
help ‘xxx’;
use xxx;
desc xxx;

4.MySQL数据类型

help ‘data types’;
help ‘decimal’

整数:

int / integer / int unsigned
bigint / bigint unsigned

小数:

decimal

字符串:

char
varchar

布尔:

boolean

日期时间:

date / time
datetime

JSON

JSON数组
JSON对象

5.表关系

一对一
多对一 / 一对多
多对多

多对一关系在多的一边添加外键列
多对多通过中间表转换成两个多对一
一对一关系是多对一关系的特例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值