在对数据进行处理上,我们经常用到的是增删查改。查就是我们上述总用到的select,这里就介绍了。接下来我们讲解一下mysql 的增删改。

(1)增加

insert into table_name (column1, column2, column3, ...) values (value1, value2, value3, ...);
insert into table_name values (value1, value2, value3, ...);

简单举例:insert into users values('17','lcamry','lcamry');

Sqli-labs Background-4 数据库增删改函数介绍

 

(2)删除

删除数据:

  • delete from 表名;  
  • delete from 表名 where id=1;  

删除结构:  

  • 删数据库:drop database 数据库名;  
  • 删除表:drop table 表名;  
  • 删除表中的列:alter table 表名 drop column 列名; 

简单举例:delete from users where id=17;

Sqli-labs Background-4 数据库增删改函数介绍

 

(3)修改

修改所有:update 表名 set 列名='新的值,非数字加单引号' ;  

带条件的修改:update 表名 set 列名='新的值,非数字加单引号' where id=6;  

简单举例:update users set username='tt' where id=16;

Sqli-labs Background-4 数据库增删改函数介绍

 

 

参考:https://www.cnblogs.com/lcamry/p/5763048.html

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2021-08-03
  • 2021-12-07
  • 2022-03-01
  • 2021-07-30
  • 2022-01-30
猜你喜欢
  • 2022-02-01
  • 2021-10-05
  • 2022-12-23
  • 2022-03-09
  • 2021-05-06
  • 2021-12-17
  • 2021-05-29
相关资源
相似解决方案