Blogger Information
Blog 25
fans 0
comment 1
visits 21957
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
SQL语句总结
潜轲的博客
Original
739 people have browsed it

DDL数据定义语言

           CREATE DATABASE IF EXISTS CHARACTER SET utf8;

              CREATE TABLE IF EXISTS ()ENGINE INNODB CHARACTER SET utf8;

              视图

              CREATE VIEW xx AS SELECT * FROM tbname;

              ALTER VIEW xx AS ELECT * FROM tbname;

              DROP VIEW xx;

              DROP DATABASE/TABLE name;

              修改数据字符集及校对集

ALTER DATABASE name charset=utg8 collate utf8_bin;(区分大小写)

              添加字段

                     ALTER TABLE name ADD 字段定义

              修改字段属性

                     ALTER TABLE name MODIFY 字段定义

              删除字段

                     ALTER TABLE name DROP

              修改字段名

                     ALTER TABLE name CHANGE old name new name字段定义

              修改表名

                     RENAME TABLE name TO name

DML数据操作语言

1.    插入数据

INSERT INTO table(字段) VALUES(值);

2.    删除数据

DELETE FROM tablename WHERE

3.    修改数据

UPDATE tablename SET 字段 = 值, …;

DQL数据查询语言

SHOW DATABASES/tables;

SELECT field FROM tbname

WHERE 条件 LIKE (模糊查询)%任意个 _一个

GROUP BY 分组

HAVING 分组后筛选条件

ORDER BY 排序

LIMIT 限制条数

五个聚合函数

AVG SUM MAX MIN COUNT(结果集记录数)

DCL数据控制语言

1.    创建用户

CREATE USER ‘user’@’ localhost’ IDETIFIED BY ‘pass

不指定host为%所有地点均可

2.删除用户

DROP USER ‘user’@’ localhost’;

3.修改密码

SET PASSWORD = password(‘pass’);

SET PASSWORD FOR user@host = password(‘pass’);

4.授权

SHOW GRANTS FOR user@host;

GRANT 权限 ON 库名.对象名 TO user@host [IDENTIFIED BY ‘pass’]

5.回收

REVOKE 权限 ON 库名.对象名 FROM user@host

权限生效

FLUSH PRIVILEGES;

 

事务

事务,是逻辑上的一组操作,做成这组操作的各个单元,要么全部成功要么全部失败

控制台

1.    start transaction 开启事务

2.    savepoint 保存点

3.    rollback to savepoint

4.    rollback没有保存点回到开头

5.    commit提交全部执行

PHP

1.$MySQLi-> begin_transaction();开启事务

2.sql语句及执行

3.commit或rollback

事务隔离级别

1.    读未提交(read  uncommitted)

2.    读已提交(read committed)

3.    可重复读(repeatable  read)

4.    可串行化(serializable)

事务四大特性

A atomicity原子***务是不可分割的一组操作,要么都发生,要么都不发生。

C consistency 一致***务使数据库一直保持一致性,开启另一个事务,上一个事务自动关闭

I isolation 隔离 :多个并发事务之间是隔离的

D durability 持久***务一旦被提交,它的改变就是永久的。


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post