2、数据操纵语言(DML),主要用于管理表中的数据,实现数据的增删改查。
插入数据:insert into
insert into tbl_name [cols....] values (val1,val2,...)
实例:insert into students (id,name) value (1,'alren');
insert into students values (2,'alren',29,'m','one');
查询数据: select
select [col1,col2,...] from tbl_name where clause;
实例:select * from students where id=1;
select name,age from students where age>11 and age
select name,age from students where age between 11 and 20;
select name,age from students where name rlike 'en$';
select age,sex from students where age is not;
select age,sex from students where age is not null;
select id,name from students order by id desc;
select id,name,age from students order by id asc;
更新数据:update
update [low_priority] [ignore] table_reference
update students set age=age+10 where name like '%lren';
删除数据:delete from
delete from tbl_name where clause;
delete from students; #删除表中的所有数据,很危险,谨慎操纵。
delete from students order by age desc limit 20;
图示:
修改表为自增长