mysql基本的增删改查操作

来源:互联网 发布:vb.net 复制文件夹 编辑:程序博客网 时间:2024/05/16 03:36

 1. 增(insert):

  1. insert into 表名 values(0,'测试');
  2. insert into 表名(id,name) values(0,'高蒙')

注:如上语句,表结构中有自动增长的列,也必须为其指定一个值,通常为0

2.删(delete):

  1. delete from 表名;
  2. delete from 表名 where id=1;

删除结构:

删数据库:drop database 数据库名;

删除表:drop table 表名;

删除表中的列:alter table 表名 drop column 列名;

3. 改(updata):

  1. 修改所有:updata 表名 set 列名='新的值,非数字加单引号' ;
  2. 带条件的修改:updata 表名 set 列名='新的值,非数字加单引号' where id=6;

4.查(select):

查询所有的数据:select *from 表名;

带条件的查询:

  1. select *from 表名 where 列名=条件值;
  2. Select * from 表名 where 列名 not likelike '字符值'

分页查询:

select *from 表名 limit 每页数量 offset 偏移量;  

0 0
原创粉丝点击