小笔记之mysql数据库

来源:互联网 发布:康佳电视的网络功能 编辑:程序博客网 时间:2024/06/05 05:14

mysql 数据库

常见数据库:

oracle (oracle,大型,收费)

db2 (IBM ,大型,收费)

SQLServer(微软,中型)

MySQL (oracle收购,6.x版开始收费)

SQLite (小型的嵌入式数据库,应用在客户端开发中,比如安卓)

sql语言:(数据库       数据库表      记录)

1.DDL(数据定义语言)

2.DML(数据操纵语言)

3.DCL(数据控制语言)

4.DQL(数据查询语言)

  一.库操作

create database 数据库名称;

show databases;

drop database 数据库名称;

use 数据库名称;

  二.表操作

      not null, unique唯一, primary key主键约束<auto_increment自动增长>

操作:

create table 表名称(

字段 类型,

字段 类型

);

 

desc 表名称;

drop table 表名称;

show tables;

insert into 表名称 values(要添加的值);

update 表名称 set 字段的名称1=修改的值1,字段的名称2=修改的值2 where 条件

delete from 表名称 where 条件

select 要查询的字段的名称 (*表示所有字段) from 表名称 where 条件

desc 表名称;select * 表名称的区别:

dest 表名称; :获取的是表格信息

select * 表名称 :获取的表格中的记录

查询表里的重复的信息

select  distinct 要查询的字段的名称 (*表示所有字段) from 表名称 where 条件

获取当前数据库:selece database();

Where:

运算符<  >  <=  >=

in(a,b);

And    or

区间 1.运算符和and结合 2.between ...and...

like  ‘通配符内   容通配符’   %:通配符,  _:必须有一个通配符

 

Order by 字段名(arc)/desc (升序/降序)

 

聚集函数

count()

Sum()

Arg()

Max()

Min()

 

4. select distinct * | 字段名 as 别名 聚集函数:count() sum() avg() max() min()

1. from table_name

2. where 

< > != = <= >=  is null  is not null

and or //and优先级高于or

in  //在那几个选项范围内

between and //在区间内

like  //模糊查询,占位符使用百分号(%) 或者 下划线(_

3. gruop by 字段名 having 聚集函数条件判断

5. order by  asc|desc

6. limit [index,[length]] //只有一个参数,表示,取前几个;两个参数,第一个是索引

    第二个是向后取值个数

 

 

0 0
原创粉丝点击