mysql数据库常用命令

命令

语法

作用

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感兴趣的小伙伴关注我。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

句号(在IT行业摸爬滚打)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值