1,mysql软件安装
2,mysql服务的启停,也可以用鼠标点击,选择控制面板的方式实现
C:\Users\Administrator>net stop mysql57
C:\Users\Administrator>net start mysql57
3,连接数据库,需要配置环境变量;
3.1找到安装mysql的位置 复制路径 C:\Program Files\MySQL\MySQL Server 5.7\bin
3.2找到path环境变量名,找到最后用英文的分号 ; 分割,然后粘贴以上复制的路径
3.3重新打开dos窗口,输入mysql命令,发现mysql命令可用
3.4连接命令
3.4.1 C:\Users\Administrator>mysql -h 127.0.0.1 -uroot -p123456
3.4.2 C:\Users\Administrator>mysql -h 127.0.0.1 -uroot -p #回车 输入密码 推荐使用这种
3.4.3 C:\Users\Administrator>mysql -uroot -p #默认登录本地服务,-h选项可以省略不写
mysql软件自带了客户端连接软件,在开始菜单栏,输入mysql搜索,选择mysql5.7 command line client ,然后输入密码登录成功
4,退出: quit exit
5,查看数据库的命令
show databases; //分号结尾,查看当前数据库服务,有几个现有数据库文件;
mysql是关系型数据库
#创建库创建表 命令关键字不区分大小写
mysql >show databases; //查看当前数据库服务器的数据库;
mysql >CREATE DATABASE schooldb; //创建数据库 ,库名叫schooldb;
mysql >use schooldb; //切换数据库
mysql >show tables; //查看当前库的表
mysql >drop database schooldb; //删除数据库,慎重!!!!!!!!!!
//建表的语法格式
mysql >create table student(
name 约束, //数据类型
age 约束,
id 约束
);
//数据类型分类:
1,数值类型; 整型: int ,bigint,浮点型:float ,double
2,字符串;char varchar
3,日期和时间;year time date
4,二进制数据类型;
练习1:建一个studentinfo表;
mysql> create table studenfinfo(
-> id char(2),
-> StudentName varchar(4),
-> Gender varchar(2),
-> BirthDay date,
-> Age int(3),
-> ClassId int(2),
-> BeginYear year,
-> Phone varchar(11),
-> province varchar(10),
-> City varchar(10),
-> Email varchar(30)
-> );
练习2:创建学校数据库并创建表
创建老师表
mysql> create table studenfinfo(
-> id char(2),
-> StudentName varchar(4),
-> Gender varchar(2),
-> BirthDay date,
-> Age int(3),
-> ClassId int(2),
-> BeginYear year,
-> Phone varchar(11),
-> province varchar(10),
-> City varchar(10),
-> Email varchar(30)
-> );
//创建班级表
mysql> create table Teacher(
-> id int(3),
-> Teachername varchar(10),
-> Hiredate date,
-> Gender varchar(2)
-> );
//创建学生表
mysql> create table Studentinof(
-> id int(4),
-> Studentname varchar(20),
-> Gender char(2),
-> Age int(3),
-> Birthday date,
-> Classid varchar(20),
-> BeginYear year,
-> Phone varchar(11),
-> province varchar(50),
-> City varchar(20),
-> Email varchar(20)
-> );
//创建课程表
mysql> Create table Subject(
-> id int(2),
-> Subjectname varchar(10),
-> Teacherid int(3));
//创建成绩表
mysql> create table Exam(
-> id int(4),
-> exam float(4,1),
-> Subjectid int(3),
-> Studentid int(4),
-> remark varchar(100));
//创建年级表
mysql> create table Grade(
-> id varchar(20),
-> GradeName varchar(10),
-> Major varchar(20));
查看schooldb的所有表;
mysql> show tables;
+--------------------+
| Tables_in_schooldb |
+--------------------+
| classinfo |
| exam |
| grade |
| studenfinfo |
| subject |
| teacher |
+--------------------+
2,使用软件连接数据 软件名 navicat
[Err] 1050 - Table 'teacher' already exists 表teacher已经存在,
在数据库里,不能有同名的表,会报错;
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'Gradeld VARCHAR (20),
BeginYear YEAR )' at line 4
语法错误,在near附近检查自己的语法
3, desc 表名; #查看当前表结构
例: desc classinfo;
修改表结构的语句
3.1 #修改表名
alter table 旧表名 rename to 新表名;
例:alter table classinof rename to classinfo;
3.2 #修改字段类型
alter table 表名 modify 字段名 类型;
例:alter table classinfo modify id int(5);
3.3 #修改字段名
alter table 表名 change 旧列名 新列名 类型;
例:alter table classinfo change id cid int(3);
3.4 删除字段;
alter table 表名 drop 字段名;
例:alter table classinfo drop cid;
3.5 添加字段:
alter table 表名 add 新字段名 类型 first ; #表示添加至第一个字段
例: alter table classinfo add id int(3) first ;
alter table 表名 add 新字段名 类型 after 已有字段名 ; #表示添加至已有字段名之后
例: alter table classinfo add id int(3) after Classname;
3.6 修改列的排列位置
alter table 表名 modify 字段名 数据类型 first;
例 : alter table classinfo modify id int(3) first;
alter table 表名 modify 字段名 数据类型 after 字段名;
alter table classinfo modify id int(3) after Classname;
第2章,数据库和表的设计
[Err] 1062 - Duplicate entry '1' for key 'PRIMARY' #错误表示主键唯一,不能重复;
[Err] 1452 - Cannot add or update a child row: a foreign key constraint fails (`schooldb`.`classinfo`, CONSTRAINT `classinfo_ibfk_1` FOREIGN KEY (`GradeId`) REFERENCES `grade` (`id`)) #添加数据失败,外键字段必须在主键值内
[Err] 1364 - Field 'BeginYear' doesn't have a default value #必须有值,不允许为空;
[Err] 1062 - Duplicate entry '123456789' for key 'Phone' #值唯一,不能重复
1,主键约束,表示数据唯一,非空; primary key
2,数据自动增长 ; auto_increment
3,外键约束, 和主键约束一块使用 foreign key
4,非空约束,字段值不允许为空; not null
5,默认约束; default
6.唯一约束; unique
create database schooldb default CHARACTER set utf8; #指定字符集,可以识别中文
#主键约束 primary key 自动增长auto_increment;
create table Grade(
id int(10) auto_increment primary key ,
GradeName varchar(20),
Major varchar(20)
);
#外键约束 foreign key
create table ClassInfo(
id int(3)auto_increment primary key,
ClassName varchar(10) not null,
BeginYear year not null,
GradeId int(10) not null,
foreign key (Gradeid) references Grade(id)
);
4,非空约束,not null ; 默认约束 default 唯一约束 unique
create table Teacher(
id int(3) not null unique,
TeacherName varchar(10),
Hiredate date,
gender varchar(2) default "男"
);
create database schooldb default CHARACTER set utf8; #指定字符集,可以识别中文
use schooldb;
create table StudentInfo(
id int(20) primary key ,
StudentName varchar(20) not null,
Gender varchar(2) not null default "男",
Age int(3) not null,
BirthDay date not null,
ClassId varchar(20) not null default "大数据8班",
BeginYear year default 2020,
Phone varchar(11) not null,
Province varchar(20) default "河南省",
City varchar(20) not null,
Email varchar(20)
);
insert into StudentInfo(id,StudentName,Age, BirthDay,Phone,city,Email)
VALUES(001,"孟令森",19,"2002-12-12","12345678910","郑州",'12345678910@163.com');
select * from StudentInfo;
insert into StudentInfo(id,StudentName,Gender,Age,BirthDay,Phone,city,Email)
values(002,"陈文静","女",20,"2001-12-12","10987654321",
"郑州",'10987654321@163.com');
insert into StudentInfo(id,StudentName,Age, BirthDay,Phone,city)
VALUES(003,"孟令森",19,"2002-12-12","12345678910","郑州");
#更新语句练习
create database schooldb default CHARACTER set utf8; #指定字符集,可以识别中文
1,新建一个成绩表,
字段 学生编号,姓名,成绩,专业,性别,级别
插入数据
(1,"刘一",50,"语文","男"),
(2,"钱二",60,"数学","男"),
(3,"张三",70,"英语","女"),
(4,"李四",80,"体育","男"),
(5,"王五",90,"语文","男"),
(6,"赵六",100,"数学","男");
2,修改所有同学的学生编号为100;
3,修改成绩在60-80之间的同学的级别为中;
4,将成绩为60以下的设置为差
5,将钱二的专业修改为计算机;
6,将男同学的体育成绩加10分;
7,将100分的同学设置为优;
insert into exam(sid,sname,sexam,major,sgender)values
(1,"刘一",50,"语文","男"),
(2,"钱二",60,"数学","男"),
(3,"张三",70,"英语","女"),
(4,"李四",80,"体育","男"),
(5,"王五",90,"语文","男"),
(6,"赵六",100,"数学","男"),
(7,"王六",80,"语文","男"),
(7,"王六",80,"语文","男");
update exam set sid=100;
update exam set level = "中" where sexam BETWEEN 60 and 80;
update exam set level = "中" where sexam >=60 and sexam <=80;
update exam set level = "差" where sexam <60;
update exam set major = "计算机" where sname = "钱二";
update exam set sexam = sexam+10 where sgender="男" and major = "体育";
update exam set level = "优" where sexam = 100;
update exam set level= "无" where level is null;
#删除语句
delete from exam where sid in (1,2,3); #最常用,记录日志,删除速度慢
truncate table exam; #不记录日志,删除速度快
create database schooldb default CHARACTER set utf8; #指定字符集,可以识别中文
use schooldb;
create table exam(
sid int,
sname varchar(10),
sexam float(4,1),
major varchar(20),
sgender varchar(2),
level varchar(1)
);
select * from exam;
insert into exam(sid,sname,sexam,major,sgender)values
(1,"刘一",50,"语文","男"),
(2,"钱二",60,"数学","男"),
(3,"张三",70,"英语","女"),
(4,"李四",80,"体育","男"),
(5,"王五",90,"语文","男"),
(6,"赵六",100,"数学","男"),
(7,"王六",80,"语文","男");
select sname,sexam from exam; #查询单个字段
select sname as 学生姓名, sexam as 学生成绩 from exam; #查询时,起别名
select sname 学生姓名, sexam 学生成绩 from exam;
select sname from exam where sexam > 60; #查询加判断条件
select distinct sgender from exam; #消除重复行
select * from exam limit 3; #限制输出行数,一个参数表示,从0开始取3行
select * from exam limit 1,3; #从1行起,不包含1,取3行
select * from exam where level is null; #判断level是空
select * from exam where level is not null; #判断level非空
select * from exam order by sexam; #按照成绩排序输出,默认正序,asc可以不写
select * from exam order by sexam asc ;
select * from exam order by sexam desc; #按照成绩排序输出,倒序输出
select * from exam order by sexam desc,sid desc; #多列排序
update exam set sid=100;
update exam set level = "中" where sexam BETWEEN 60 and 80;
update exam set level = "中" where sexam >=60 and sexam <=80;
update exam set level = "差" where sexam <60;
update exam set major = "计算机" where sname = "钱二";
update exam set sexam = sexam+10 where sgender="男" and major = "体育";
update exam set level = "优" where sexam = 100;
update exam set level= "无" where level is null;
delete from exam where sid in (1,2,3); #最常用,记录日志,删除速度慢
truncate table exam; #不记录日志,删除速度快
#字符串函数
select concat("今天","明天"); #连接字符串
select length("Hello World"); #获取字符串长度
select upper("Hello World"); #将字符全部转换为大写
select ltrim(" abc"); #去除左边空格
select rtrim("abc "); #去除右边空格
select trim(" abc "); #去除两边空格
select replace("abcccd","c","x"); #将abcccd中的c替换为x
select strcmp("a","b"); #比较两个字符串大小,a < b 返回 -1
select strcmp("b","a"); #比较两个字符串大小,b > a 返回 1
select strcmp("a","a"); #比较两个字符串大小,a = a 返回 0
select substring("Johnson",5,3); #字符串截取,从第5个位置开始截取3个字符串
#时间函数
select now(); #获取当前日期+时间
select curdate(); #获取当前日期
select curtime(); #获取当前时间
select month(now()); #返回日期对应的月份,数字类型 范围 1-12;
select monthName(now()); #返回日期对应的月份,英文名;
select dayname(now()); #返回日期对应的工作日的英文名;
select dayofweek(now()); #返回日期对应的一周中的索引,1代表周日
select weekday(now()); #返回日期对应的工作日的索引,0表示周一
select week(now()); #计算日期是一年中的第几周,范围 1-52;
select dayofyear(now()); #计算日期是一年中的第几天,范围 1-365
select dayofmonth(now()); #计算日期是一月中的第几天,范围 1-31;
select year(now()); #返回日期中年份,范围1000到9999;
select quarter(now()); #返回日期对应的一年中的季度值,范围 1-4
select minute(now()); #返回时间的分钟部分,范围 0 -59;
select second(NOW()); #返回时间的秒部分,范围 0 - 59;
#计算时间和日期
select now();
set @dt=now(); #设置一个变量,变量名叫@dt;
select date_add(@dt,interval 1 day); #为日期增加时间间隔, 1天
select @dt; #查看变量的值
select adddate(@dt,interval 1 day); #为日期增加时间间隔, 1天
select date_sub(@dt,interval 1 day); #为日期减少时间间隔, 1天
select subdate(@dt,interval 1 day); #为日期减少时间间隔, 1天
select addtime("10:10:10","20:20:20"); #时间相加
select datediff("2019-12-25","2019-12-22"); #时间相减
#数学函数
select format(3.1415926,3); #format(x,y)将一个数字x,四舍五入的方式 保留小数位y位;
select abs(-3); #求一个数的绝对值
select abs(3);
select sqrt(9); #求一个数的平方根;
select mod(6,4); #mod(x,y) x是除数,y是被除数,结果是余数
select ceil(2.6); #向上取整
select floor(2.6); #向下取整,小数去尾法
select rand(); #生成随机数
select truncate(3.1415926,3); #truncate(x,y) 直接将x的y为小数直接删除
select sign(5); #1
select sign(-5); # -1
select sign(0); #0 #返回当前结果的符号,负数返回负1,整数返回正1,0返回0;
select power(2,32); #power(x,y) 幂运算,返回x的y次方
select round(3.1415926); #将数值表达式四舍五入为指定位数,一个参数默认为整数
select ROUND(3.1415926,3); #将数值表达式四舍五入为指定位数;
#系统函数
select database(); #返回当前数据库库名
select benchmark(5000,(select now())); #benchmark(count,expr) 将expr执行count次,返回结果始终是0,可以计算执行的时间;
select connection_id(); #返回当前客户的连接id
select found_rows();
select version(); #返回当前服务器版本
select user(); #返回当前登录用户
CREATE TABLE `classinfo` (
`id` int(3) DEFAULT NULL,
`classname` varchar(20) DEFAULT NULL,
`gradeld` int(3) DEFAULT NULL,
`beginyear` year(4) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `exam` (
`id` int(5) DEFAULT NULL,
`exam` int(3) DEFAULT NULL,
`subjectid` int(2) DEFAULT NULL,
`studentid` int(5) DEFAULT NULL,
`remark` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `grade` (
`id` int(2) DEFAULT NULL,
`gradename` varchar(20) DEFAULT NULL,
`major` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
;
CREATE TABLE `studentinfo` (
`id` int(3) DEFAULT NULL,
`studentname` varchar(20) DEFAULT NULL,
`gender` varchar(10) DEFAULT NULL,
`age` int(3) DEFAULT NULL,
`birthday` date DEFAULT NULL,
`chassid` int(3) DEFAULT NULL,
`beginyear` year(4) DEFAULT NULL,
`phone` int(20) DEFAULT NULL,
`province` varchar(50) DEFAULT NULL,
`city` varchar(50) DEFAULT NULL,
`email` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `subject` (
`id` int(2) DEFAULT NULL,
`subjectname` varchar(50) DEFAULT NULL,
`teacherid` int(3) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `teacher` (
`id` int(3) DEFAULT NULL,
`teachername` varchar(20) DEFAULT NULL,
`hiredate` date DEFAULT NULL,
`gender` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
##修改表结构
use schooldb; #切换数据库
show tables; #查看数据表
alter table exam RENAME to exama; #修改表名
desc exama; #查看表的数据类型
alter table exama modify remark varchar(100); #修改字段数据类型
desc studentinfo; #查看表结构类型
alter table studentinfo change gender sex varchar(20); #修改学生性别字段名
alter table studentinfo drop email;#删除列
alter table studentinfo add email varchar(20); #增加列
alter table studentinfo modify sex varchar(20) after age; #修改字段位置
drop table 表名; #删除表
#主键约束
SHOW TABLES; #查看表
drop table grade; #删除表
#创建表并定义主键为id
create table grade(id int(3) primary key,name varchar(20));
insert into grade(id,name) VALUES(1,"tom"); #插入内容
insert into grade(id,name) VALUES(1,"tm"); #插入内容,id重复会报错
select * from grade; #查询表内容,只有一条数据
#创建表a不定义主键
create table a(id int(2),name varchar(2));
insert into a values(1,"m"); #插入内容
insert into a values(1,"tm"); #插入内容,id重复插入。
select * from a; #查看表内容
#创建表b定义主键 ,主键定义方式的不同。
create table b(id int(4),name varchar(20),PRIMARY key(id));
insert into b values(1,"m"); #插入语句成功
insert into b values(1,"m");#插入失败,id不能重复
insert into b values(2,"m");#插入成功
select * from b; #查询b表,有两条数据
+++++++++++++++++++++++++++++++++++++++++++++++++++++
create database schooldb; #创建数据库
use schooldb; #切换数据库
create table a( #创建数据表,定义主键
id int(2) primary key,
age int(2),
name varchar(20)
);
select * from a ; #查询a表数据
insert into a values(1,20,"a"); #插入数据
insert into a values(1,20,"a"); #插入数据 会报错 id不允许重复
create table b( #创建b表,定义主键,定义方式的不同
id int(2) ,
age int(2),
name varchar(20),
primary key(id)
);
create table c( #创建c表,定义联合主键
id int(2),
age int(2),
name varchar(20),
primary key(id,name)
);
insert into c values(1,20,"a"); #插入数据,
insert into c values(1,20,"b"); #插入数据
insert into c values(2,20,"a"); #插入数据
insert into c values(1,20,"a"); #插入数据,联合主键的值不允许同时相同
select * from c; #查询c表数据
create table d( #创建d表,设置id值的自动增长,定义id之为主键
id int(2) auto_increment primary key,
age int(2),
name varchar(20)
);
insert into d(age,name) values(2033,"a"),(30,"b"); #插入数据,显示id值自动增长
select * from d; #查询d表值
create table e( #创建e表,定义外键,d表为主键表
id int(2),
classname varchar(20),
foreign key(id) references d(id)
);
insert into e(id,classname) values(111,"a"),(222,"b"); #插入数据,id值只允许为d表的id值
insert into e(id,classname) values(1,"a"),(2,"b"); #插入数据
select * from e; #查询e表数据
create table f( #创建f表,设置name字段不允许为空
id int(2),
name varchar(20) not null #不允许为空
);
insert into f values(1,"f"); #插入数据
insert into f(id) values(2); ##插入数据,name字段不允许为空
select * from f; #查询f表数据
create table g( #创建g表
id int(2),
name varchar(20)
);
insert into g(id) values(1),(2); #插入数据,同时插入多条
select * from g; #查询g表数据
create table h( #创建h表,定义默认值
id int(2),
sex varchar(10) default "m"
);
insert into h(id,sex) values(1,"w"); #插入数据
select * from h; #查询h表数据
create table i( #创建i表,定义字段不允许为空,并定义unique唯一值
id int(2),
age int(2),
nid int(3) not null unique #值唯一
);
insert into i(id,age,nid) values(1,2,3),(1,2,4); #插入数据
select * from i; #查询i表数据
[Err] 1007 - Can't create database 'schooldb'; database exists #报错信息,库已经存在,不能重复创建。
[Err] 1050 - Table 'exam' already exists #报错信息,表已经存在,不能重复创建
create database schooldb; #创建schooldb库
use schooldb; #进入schooldb库
create table exam( id int(3),name varchar(20),age int(3),gender varchar(5),exam int(3)); #创建表
insert into exam values(1,"aa",20,"w",80); #插入数据
insert into exam(id,name,age,gender,exam) values(2,"bb",21,"w",85); #插入数据
insert exam values(3,"cc",18,"w",90); #插入数据
insert exam(id,name,age,exam) values(4,"dd",17,95),(5,"ee",18,98); #插入数据
select name,exam from exam where gender is not null; #查询单个字段值,判断条件,字段是否不为空
select name,exam from exam where gender is null; #查询单个字段值,判断条件,字段是否为空
select name,exam from exam where exam > 85; #查询单个字段值,判断条件,字段大于数值
select name,exam from exam where exam < 95; #查询单个字段值,判断条件,字段小于数值
select name,exam from exam where age >=18; #查询单个字段值,判断条件,字段大于等于数值
select name,exam from exam where age <=18; #查询单个字段值,判断条件,字段小于等于数值
select * from exam; #查询表的所有数据
select id as xuhao from exam; #查询字段值并定义别名
select id xuhao from exam; #查询字段值并定义别名
select DISTINCT gender from exam; #查询字段值并取消重复行
——————————————————————————————————————
create database schooldb;
use schooldb;
create table subject(
id int(2) auto_increment primary key,
subjectname varchar(20),
teacherid int(2)
);
insert into subject(subjectname,teacherid)
values("shuxue",10),("yuwen",10),("yingyu",null),
("tiyu",40);
delete from subject; #删除表数据
delete from subject where 条件语句; #根据条件删除数据
TRUNCATE table subject; #清空表
select * from subject; #查询所有
select id,teacherid from subject; #查询单个字段值
select id from subject where teacherid is null; #查询单个字段值,加条件判断,字段是否为空
select id from subject where teacherid is not null; #查询单个字段值,加条件判断,字段是否不为空
select DISTINCT teacherid from subject ; #查询单个字段值,取消重复行
select * from subject where id=teacherid or teacherid > 20; #查询所有内容,多重条件判断
select subjectname from subject where id >2 and teacher is null; #查询所有内容,多重条件判断
select * from subject limit 2; #查询所有内容,限制条数
#根据id排序默认正序,倒序为desc
select * from subject order by id desc ; #查询所有内容,排序, asc正序为默认可以不写,desc倒序排列
desc subject; #查看表结构
————————————————————————————————————
create database schooldb;
use schooldb;
show tables;
CREATE TABLE `exam` (
`id` int(3) ,
`name` varchar(20) ,
`age` int(3) ,
`gender` varchar(5) ,
`exam` int(3)
) ENGINE=InnoDB DEFAULT CHARSET="utf8" ;
insert into exam values(1,"张三三",18,"男",80),
(2,"aa啊",19,"nv",85),(3,"bb并",20,"nan",90);
select * from exam;
查询成绩大于80的学生,
查询年龄大于15的学生,并且按照id倒序排列
select name from exam where exam>80;
select id,name,exam from exam where age > 15 order by id desc;
select id,name from exam where name like "%三"; #模糊匹配,%匹配所有
select id,name from exam where name like "_三"; #模糊匹配,_匹配单个字符
select sum(exam) from exam ; #聚合函数,查询成绩的总和
select avg(exam) from exam ; #聚合函数,查询成绩的平均值
select count(name) from exam; #聚合函数,统计学员的数量
select min(exam) from exam; #聚合函数,统计最小成绩
select max(exam) from exam; #聚合函数,统计最大成绩
select * from exam group by name; #分组查询,
select * from exam group by name,gender; #多列分组查询,
#多表查询
create database schooldb;
use schooldb;
create table schooldb.T_a(A1 varchar(5),A2 varchar(5));
create table T_b(B1 varchar(5),B2 varchar(5),A1 varchar(5));
insert into T_a values("A11","A21"),("A12","A22"),
("A13","A23"),("A14","A24");
insert into T_b values("B11","B21","A11"),("B12","B22","A12");
#("B13","B23","A13"),("B14","B24","A14");
#交叉链接查询
select T_a.*,T_b.* from T_a,T_b where T_a.A1=T_b.A1 ;
#内连接查询
select T_a.*,T_b.* from T_a inner join T_b on T_a.A1=T_b.A1 ;
#左外链接
select a.*,b.* from T_a as a left join T_b b on a.A1=b.A1;
#右外链接
select a.*,b.* from T_a as a right join T_b b on a.A1=b.A1;
delete from T_b ;
select * from T_b;