随笔分类 -  MySQL

Mysql储存过程8:repeat循环
摘要:语法: 就是相当于其他语言中的: 阅读全文

posted @ 2017-07-04 08:23 Perl6 阅读(1395) 评论(0) 推荐(0)

Mysql储存过程7: case
摘要:注意这个case用在储存过程中与用在查询语句中是不一样的。 储存过程中要用end case结束, 用在一般查询中是end结束。 用法可参以参考一下这里: http://www.cnblogs.com/perl6/p/6995593.html 阅读全文

posted @ 2017-07-04 08:02 Perl6 阅读(256) 评论(0) 推荐(0)

Mysql储存过程6: in / out / inout
摘要:in 为向函数传送进去的值 out 为函数向外返回的值 intout 传送进去的值, 并且还返回这个值 调用时: call q1(1, @value); 注意, 第二个参数要为变量定义的型式。 这个函数并没有向外发送改变后的name值, 所以调用后 select @value 为null。 再看看o 阅读全文

posted @ 2017-07-04 07:43 Perl6 阅读(231) 评论(0) 推荐(0)

Mysql储存过程5: while
摘要:循环结构 while create procedure name() begin while 条件 do SQL语句 end while; end$ create procedure aa6() begin declare number int default 0; while number create procedur... 阅读全文

posted @ 2017-07-04 07:15 Perl6 阅读(338) 评论(0) 推荐(0)

Mysql储存过程4:mysql变量设置
摘要:默认全局变量是两个@@开头, 可用show variables查看所有默认变量: @@user #declare定义变量只能用在储存过程中 #declare 变量名 数据类型 可选类型 declare num int; declare age int defalut 100; #定义全局变量, 可以 阅读全文

posted @ 2017-07-04 06:49 Perl6 阅读(333) 评论(0) 推荐(0)

Mysql储存过程3:if语句
摘要:--if/else语句 if 条件 then SQL语句 else SQL语句elseifSQL语句 end if; create procedure test1( number int ) begin if number > 10 then select user(); else select 'please input a number > 10'; ... 阅读全文

posted @ 2017-07-04 06:34 Perl6 阅读(493) 评论(0) 推荐(0)

Mysql储存过程2:变量定义与参数传递
摘要:#储存过程 中的变量定义 declare 变量名 类型 可选类型 -- 跟建表差不多 create procedure p() begin declare age int default(18); declare number int default 1; select age+number; end$ /* mysql> create procedure p(... 阅读全文

posted @ 2017-07-04 06:26 Perl6 阅读(960) 评论(0) 推荐(0)

Mysql储存过程1: 设置结束符与储存过程创建
摘要:#显示储存过程 show procedure status; #设置结束符 delimiter $; #创建储存过程 create procedure procedure_name() begin --sql语句 end$ create procedure myshow() begin select 阅读全文

posted @ 2017-07-04 06:14 Perl6 阅读(1255) 评论(0) 推荐(0)

Mysql中的primary key 与auto_increment
摘要:mysql> create table cc(id int auto_increment); ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be def in 阅读全文

posted @ 2017-07-04 05:25 Perl6 阅读(5879) 评论(1) 推荐(1)

Mysql中的索引
摘要:索引: 为了加快查找速度 普通索引: index 唯一索引: unique index 维一索引可以有多个 主键索引: primary key 不能重复 主键必定要维一 一张表上只有一个主键 全文索引: fulltext index 查看索引: show index from table_name; 建立索引: alter table table_name ad... 阅读全文

posted @ 2017-07-04 04:57 Perl6 阅读(256) 评论(0) 推荐(0)

Mysql备份与恢复
摘要:备份: 某个库里的所有表: mysqldump -u root -proot dbname > /path/filename.sql 库下面的某个表: mysqldump -u root -proot dbname table1 table2 ...> /path/filename.sql 多个库: mysqldump -u root -proot -B dbname1 dbname2 ... 阅读全文

posted @ 2017-07-04 04:19 Perl6 阅读(136) 评论(0) 推荐(0)

Mysql中的事务
摘要:事务: 开启: start transaction; commit提交 rollback 回滚 执行执作前开启 确定无误时, commit提交 每一次commit/rollback后一个事务就算完成了 下次要用还要用start transaction开启 注意, 有一些语句会隐式地提交事务 没有事务时: sql -> 表数据 用事务时: sql -> 事务日志文件 ->... 阅读全文

posted @ 2017-07-04 04:07 Perl6 阅读(183) 评论(0) 推荐(0)

Msql中的触发器
摘要:解发器 当执行某种操作时解发的行为。 比如, 当表变动时触发的动作。 像商城订单, 当下单时, 库存减少。 语法: create trigger trigger_name after/befor insert/update/delete on 表名 for each row(这句话固定的) begin sql语句 #一句式多句 end; 单纯触发器执行一条SQL语句, 可以把begi... 阅读全文

posted @ 2017-07-04 03:41 Perl6 阅读(191) 评论(0) 推荐(0)

mysql中的视图
摘要:#视图创建: create view view_name as select ...... #删除视图: drop view view_name; mysql> create view user as select user,password from mysql.user; Query OK, 0 rows affected (0.03 sec) mysql> select * fr... 阅读全文

posted @ 2017-07-04 02:38 Perl6 阅读(148) 评论(0) 推荐(0)

mysql中列的增删改
摘要:增加列: alter table table_name add name varchar(100); alter table table_name add name varchar(100) after id; alter table table_name add name varchar(100) first; 修改列名: alter table table_name change nam... 阅读全文

posted @ 2017-07-03 21:45 Perl6 阅读(224) 评论(0) 推荐(0)

Fuzz安全狗注入绕过
摘要:安全狗版本为: apache 4.0 网站为: php+mysql 系统: win 2003 这里只要是fuzz /*!union 跟 select*/ 之间的内容: 位置很多可以选择。 脚本语言你可以用你喜欢的, 我这里用perl6 让我们一步步来。 枸造 exp 我用如下代码(代码测试用): 字 阅读全文

posted @ 2017-06-25 12:42 Perl6 阅读(5724) 评论(1) 推荐(0)

MySQL join 用法
摘要:select column1, column2 from TABLE1 join TABLE2 on 条件 # select * from table1 join table2; #两个表合成一个select a.*, b.* from a left join b where a.id=b.id limit 0,1; on 条件 where/ group by / having/ ... 阅读全文

posted @ 2017-06-24 14:50 Perl6 阅读(438) 评论(0) 推荐(0)

mysql 复制表结构 / 从结果中导入数据到新表
摘要:这只会复制结构: 这除了复制结构, 还会复制结果集: 用法例子: 阅读全文

posted @ 2017-06-21 08:36 Perl6 阅读(426) 评论(0) 推荐(0)

mysql limit
摘要:limit n,m 取出第n行到第m行的数据 limit n 相当于 limit 0,n 阅读全文

posted @ 2017-06-21 08:04 Perl6 阅读(172) 评论(0) 推荐(0)

mysql where/having区别
摘要:只要区别就是: where只对数据库里的所有数据进行查询 having只对结果集进行查询 阅读全文

posted @ 2017-06-21 08:00 Perl6 阅读(209) 评论(2) 推荐(0)

导航