SQL
文章平均质量分 52
czjuttsw
Learning, staying up to date, and working on the latest and greatest in languages and APIs is what keeps me excited.
展开
-
实例测试Mysql使用索引带来的效率提升
创建数据库:CREATE DATABASE `sql_learn_db`;创建一个表:Create Table: CREATE TABLE `persons` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `LastName` varchar(255) DEFAULT NULL, `FirstName` varchar(255) D原创 2013-01-09 19:25:55 · 1610 阅读 · 0 评论 -
一个简单的SQL注入
本例采用JSP+Servlet+Mysql:1. 数据库:数据库名:sqlinjectCREATE DATABASE sqlinject;建user表: Table: userCreate Table: CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varc原创 2012-10-10 15:15:43 · 3205 阅读 · 8 评论 -
简单使用MySQL的存储过程
MySQL5.0版本引进了存储过程的概念。存储过程可以提高执行效率,更容易维护。在没有存储过程(procedure)概念之前,通常的业务逻辑sql代码有时很长,它们一般被嵌入在宿主语言(比如Java)中,非常不便于维护,而有了存储过程,它们被定义在数据库端,并且进行了预编译。而且业务逻辑SQL代码无需在网络中传输,减轻了网络负担。可以说存储过程的优点大于它的缺点。下面实现一个简单的加法存储原创 2013-03-07 22:58:44 · 2022 阅读 · 0 评论 -
MySQL导入的sql脚本文件过大解决方案
默认情况下,MySQL的最大允许包(max_allowed_packet)是1048576B(1MB)当向MySQL导入的sql脚本文件超过1MB时,此时导入就会出现问题。解决方案是修改MySQL的my.ini配置文件。在my.ini文件中任意位置添加max_allowed_packet = 100M其中100M是随便给出的一个数字,可自行根据脚本文件大小进行修改。原创 2013-08-06 11:32:58 · 4412 阅读 · 1 评论 -
数据库表查询-对查询的列进行操作
如上表所示,如何将num字段的YES变成Y,而NO变成N,即如下图:SQL:(postgresql)select id,case when num = 'YES' then 'Y' when num = 'NO' then 'N' else 'error'end as resultfrom example数据库表结构:CREATE T原创 2014-02-10 11:20:59 · 1588 阅读 · 0 评论