命令 | 语法 | 作用 |
---|---|---|
select | select [column] from [table] where [condition] | 查询表中数据 |
update | update [table] set [column=value] where [condition] | 更新表中数据 |
insert | insert into [table](column1,...,columnN) values(value1,...,valueN),(value2,...,value2N) | 在表中插入数据 |
delete | delete from [table] where [condition] | 删除表中数据 |
create table | create [table](column1 type1,column2 type2,...,columnN typeN) | 创建新表 |
create table(like) | create table [table] like [exist_table] | 复制已存在的表以创建新表(不复制内容) |
create table(as) | create table [table] as (select [columns] from [exist_table] where [condition]) | 复制已存在的表中部分数据以创建新表(复制内容) |
left join | select [column] from [table1] left join [table2] on [table1.col]=[table2.col] where [condition] | 左链接,最左边的table1所有行都在 |
right join | select [column] from [table1] right join [table2] on [table1.col]=[table2.col] where [condition] | 右链接,最右边的table2所有行都在 |
inner join | select [column] from [table1] inner join [table2] on [table1.col]=[table2.col] where [condition] | 内链接,链接的所有table都有的行在 |
drop table | drop table [table] | 删除表 |
use | use [database] | 选择操作数据库 |
show | show databases、show tables | 显示数据库、显示表 |
匹配字段常用like,如select * from [table1] where [column] like '%123%'
欢迎对IT感兴趣的小伙伴关注我。