mysql数据库的DDl和DML

来源:互联网 发布:福建警察学院网络 编辑:程序博客网 时间:2024/05/16 07:46
现在在学jdbc里面有数据库语句的简单操作,所以我就先写点简单的mysql语句框框:

DDL:

    create    drop   alter:

1.create:

 create table 表名 (列名1 数据类型 【约束】,......);
主要存在的约束有:not null,primary key ,auto_increment,unique,foreign key.....
2.drop:

drop table [if exists] tab_name;
drop 列名

3.alter
alter table 表名

DML:
insert    update   delete    select :
1.insert:

insert into 表名 values(值1,值2...........);
insert into 表名  (列1,列2 ,列3 .....)values (值1,值2,值3......);
insert into 查询语句;

2.select:(查询语句):

select 列名| 表达式|*;
          from 表名
          where条件:①>,<,=,!=,>=,<=;
                               ②between and
                               ③is null ,is not null....
         ④like:_任意一个,%多个
                               ⑤and ,or            
       ⑥group by(和聚合函数一起:count(),sum(),avg(),max(),min())
         ⑦order by(asc,desc)

3.update:

update  表名  set 列名1=值,列名2=值;

4.delete:

delete from 表名;

好啦,是不是觉得特别简单,可是小哥哥我在前端和java都学过一遍,愣生生没背下来,可能是还要多练习。快哭了

原创粉丝点击