%匹配任意长度的字符串,包括空字符串
_下划线通配符只匹配单个字符
规则
sql
结构化查询语言
删除命令:
drop database 数据库名称;
把数据库删除
drop table 表名称;
把表删掉
delete from 表名 [where 条件] [order by 排序的字段 [desc 取反]] [limit 限定的行数];
删除表中数据,最好加where字句,用主键,增长 id 会继续增长。(不加条件则删除全部内容,id还是继续增长。)
truncate 直接加表名
删除表中数据,再插入时自增长id又从1开始
更新(修改) update
update 表名 set 字段名1=值表达式1,字段名2=值表达式2,....[where条件] [order排序] [limit限定];
![](https://img.haomeiwen.com/i18938642/b30cc2325b8ad6e1.png)
![](https://img.haomeiwen.com/i18938642/91e68dc6c0ed6d2c.png)
![](https://img.haomeiwen.com/i18938642/8e27ced64a8de4eb.png)
create database servers;
use servers
status
create table phy_server(
id int auto_increment primary key,
host_name varchar(36) unique key not null,
server_model varchar(96) not null,
server_sn varchar(128) not null,
server_vendor varchar(96) not null comment "厂商",
board_sn varchar(96),
bios_version varchar(96) not null,
os_version varchar(96) not null,
kernel_version varchar(96) not null,
cpu_phy_num int,
cpu_core_of_phy int,
cpu_model varchar(32),
add_date datetime,
change_date datetime default now()
);
desc phy_server;
查看结构
insert into phy_server(host_name,server_model,server_sn,
)
bios_version,
....
)
values(
'kvm-docker',
'PowerEdge_R710',
"4c4c4544-0059",
"Dell_Inc",
"CN1374006T00B7" )
select * form phy_server;
匹配列前缀查询
name like 'shark%'
匹配范围值查询
name > 'a' and name < 'c'
![](https://img.haomeiwen.com/i18938642/a901a97469e7ab7c.png)
![](https://img.haomeiwen.com/i18938642/6240e7d34226722b.png)
![](https://img.haomeiwen.com/i18938642/974b8a12fff9cd17.png)
![](https://img.haomeiwen.com/i18938642/fd205a3ec57fb7eb.png)
![](https://img.haomeiwen.com/i18938642/e06de9fd035d4af4.png)
![](https://img.haomeiwen.com/i18938642/3b2ec65a9041e2a0.png)
![](https://img.haomeiwen.com/i18938642/1afb258c1645370b.png)
![](https://img.haomeiwen.com/i18938642/b7344163806fa5f5.png)
![](https://img.haomeiwen.com/i18938642/57887dac7a1a680d.png)
![](https://img.haomeiwen.com/i18938642/c8bb1c88155ea012.png)
![](https://img.haomeiwen.com/i18938642/3a5378c94d5bab80.png)
![](https://img.haomeiwen.com/i18938642/031a2a0dd308f422.png)
![](https://img.haomeiwen.com/i18938642/9201074ea5143a0a.png)
![](https://img.haomeiwen.com/i18938642/5ddfd7ac7bf88100.png)
![](https://img.haomeiwen.com/i18938642/ace2cc05abf0fe78.png)
create view server as select id,host_name,os_version,server_model from phy_server; 创建视图
![](https://img.haomeiwen.com/i18938642/cae5a6d2dbc101d3.png)
网友评论