mysql基础
来源:互联网 发布:淘宝打印助手在哪里 编辑:程序博客网 时间:2024/05/21 12:42
1)mysql存储结构: 数据库-> 表-> 数据 sql语句
2)管理数据库:
增加: create database 数据库 default character utf8;
删除: drop database 数据库;
修改: alter database 数据库 default character gbk;
查询: show databases / show create database 数据库;
3) 管理表:
选择数据库:use 数据库;
增加: create table 表(字段名1字段类型,字段名2字段类型......);
删除: drop table 表;
修改:
添加字段: alter table 表 add [column] 字段名 字段类型;
删除字段: alter table 表 drop [column] 字段名;
修改字段类型: alter table 表 modify 字段名 新的字段类型;
修改字段名称 : alter table表 change 旧字段名 新字段名 字段类型;
修改表名称: alter table 表 rename [to] 新表名;
查询:
show tables / desc student;
4) 管理数据:
增加: insert into 表(字段1,字段2,。。。) values(值1,值2.。。。。);
删除: delete from 表 where 条件;
修改: update 表 set 字段1=值1,字段2=值2...... where 条件;
查询:
4.1)所有字段: select * from表;
4.2)指定字段: select字段1,字段2.... from表;
4.3)指定别名: select字段1 as别名 from表;
4.4 )合并列: select (字段1+字段2) from表;
4.5)去重: select distinct字段 from表;
4.6)条件查询:
a)逻辑条件 :and(与) or(或)
select * from 表 where条件1 and/or条件2
b)比较条件: > < >= <= = <> between and(在。。。之间)
select * from 表 where servlet>=90;
c)判空条件:
判断null: is null / is not null
判断空字符串: ='' / <>''
d)模糊条件: like
%: 替换任意个字符
_: 替换一个字符
4.7 分页查询:limit起始行,查询行数
起始行从0开始
4.8 排序: order by字段 asc/desc
asc: 正序,顺序
desc:反序,倒序
4.9 分组查询:group by字段
4.10: 分组后筛选: having条件
SQL语句的分类:
DDL: 数据定义语言
create / drop / alter
DML:数据操作语句
insert / delete /update / truncate
DQL: 数据查询语言:
select / show
- MySQL基础
- MySQL基础
- MySql基础
- MySQL基础
- mysql基础
- MYSQL基础
- MySQL基础
- mysql基础
- mysql基础
- MySQL 基础
- mysql基础
- mysql基础
- mysql 基础
- MySQL基础
- MySql 基础
- mysql基础
- mysql基础
- mysql基础
- 解决memory bound算法的一些建议
- HTTP之URI和URL
- Linux使用经验
- HDU 6241 Color a Tree CCPC2017 Harbin(二分答案+上下界判定)
- 日常总结
- mysql基础
- classpath路径及ClassPathXmlApplicationContext()用法
- hihoCoder-----有歧义的号码
- 入主tensorflow前言
- 四大组件之contentProvider简单数据库
- weui.js slider的使用笔记
- 校正Linux系统时间并把系统时间写入硬件
- Magento常用过滤筛选器
- C#命名规则