MySql创建函数
首先需要查看一下创建函数的功能是否开启:
mysql> show variables like '%func%';
+-----------------------------------------+-------+
| Variable_name | Value |
+-----------------------------------------+-------+
| log_bin_trust_function_creators | ON |
+-----------------------------------------+-------+
1 row in set (0.02 sec)
如果Value处值为OFF,则需将其开启。
mysql> set global log_bin_trust_function_creators=1;
创建函数时,先选择数据库,
mysql> use xxx;
Database changed
delimiter $$是设置 $$为命令终止符号,代替分号,因为分号在begin...end中会用到;
mysql> delimiter $$
CREATE FUNCTION first_func(param1 varchar(5),parmam2 varchar(5),param3 varchar(10))
RETURNS TINYINT
BEGIN
RETURN 1;
END
函数创建成功后需恢复分号为命令终止符号。
mysql> delimiter ;
测试:
mysql> select first_func('aaa','bbb','ccc');
+-------------------------------+
| first_func('aaa','bbb','ccc') |
+-------------------------------+
| 1 |
+-------------------------------+
1 row in set (0.47 sec)
删除函数:
mysql> drop function first_func ;
Query OK, 0 rows affected (0.11 sec)
查看函数
1) show function status
显示数据库中所有函数的基本信息
2)查看某个具体函数
mysql>show create function bobj.first_func;
相关文档:
Real example:
/*************************by garcon1986*********************************************************/
<?php
// get the values from entreprise creation form
$secteur = $_POST['secteur'];
$nom = $_POST['nom_entreprise'];
$taille = $_POST['taille_entreprise'];
$concurrent = $_POST[' ......
Beware of MySQL Data Truncation
http://www.mysqlperformanceblog.com/2009/02/07/beware-of-mysql-data-truncation/
比如:有一个表aritcle和另一个表article_comment,关联是article的id
CREATE TABLE `article` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(200) NOT NULL,
......
Accessing Distributed Data with the Federated Storage Engine
http://dev.mysql.com/tech-resources/articles/mysql-federated-storage.html
Federated存储引擎可以使几台数据库逻辑上组成一个数据库,其作用相当于Oracle的数据库链接,通俗地说,即在本地建立远程的数据库表的引用。
Mysql需要5.0以上
(1)查看是 ......
轉自花開的地方
mysql有一个功能就是可以log下来运行的比较慢的sql语句,默认是没有这个log的,为了开启这个功能,要修改my.cnf或者在mysql启动
的时候加入一些参数。
如果在my.cnf里面修改,需增加如下几行
long_query_time = 1
log-slow-queries
=
log-queries-not-using-indexes
long_query_t ......
Perl中DBI、DBD::mysql模块的安装
使用的软件版本
DBI-1.604.tar.gz
DBD-mysql-4.006.tar.gz
建议使用以上版本搭配,否则可能连接mysql错误
一、DBI的安装
wget http://www.cpan.org/modules/by-module/DBD/DBI-1.604.tar.gz
tar -zxvf DBI-1.604.tar.gz
cd DBI-1.604
perl Makefile.PL ......