SQL的核心基础语法 | 快速入门MySQL

SQL核心基础语法
create database 数据库名; #新建数据库
use 数据库名; #指明数据库
create table 表格名 ( 列名1 int auto_increment primary key, 列名2 varchar() not null, 列名3 date null); #int整形,varchar字符型,date日期
insert into 数据库名.表格名(列名1,列名2,列名3) values (数值1,数值2,数值3); #插入
select * from 表格名 /select 列名1 列名2 from 表格名 #查询
select distinct * from 表格名 #查询去重
select * from 表格名 where(not) 条件 order by 列名 desc #分组排序 desc从高到低,从大到小/默认为asc
alter table 数据库名.表格名 add 列名 数据类型 默认条件 #alter table egg.eggs_record add stock int null; ##增加表格列名
updata 数据库名.表格名 set where 条件 #更新
delete from 数据库名.表格名 #删数据
drop table 数据库名.表格名 #删表
drop database 数据库名 #删库
select * from inner 表1 join 表2 on 表1.列名1 = 表2.列名1; #取交集
select country from 表1 union select country from 表2 # union all 有重复值
select * from 表1 left join 表2 on 表1.列名1 = 表2.列名1; #左连接
select * from 表1 rigtht join 表2 on 表1.列名1 = 表2.列名1 #右连接