sql常用增删查改语句

 

  • 1. 增:  
  • insert into 表名 values(0,'测试');  
  • 注:如上语句,表结构中有自动增长的列,也必须为其指定一个值,通常为0  
  • insert into 表名(id,name) values(0,'尹当')--同上  
  • 2.删数据:  
  • delete from 表名;  
  • delete from 表名 where id=1;  
  • 删除结构:  
  • 删数据库:drop database 数据库名;  
  • 删除表:drop table 表名;  
  • 删除表中的列:alter table 表名 drop column 列名;  
  • 3. 改:  
  • 修改所有:updata 表名 set 列名='新的值,非数字加单引号' ;  
  • 带条件的修改:updata 表名 set 列名='新的值,非数字加单引号' where id=6;  
  • 4.查:  
  • 查询所有的数据:select *from 表名;  
  • 带条件的查询:  
  • select *from 表名 where 列名=条件值;  
  • Select * from 表名 where 列名 not like(like) '字符值'  
  • 分页查询:select *from 表名 limit 每页数量 offset 偏移量; 

 

posted @ 2014-05-15 13:55  mcdullsin  阅读(545)  评论(1编辑  收藏  举报