里面包含mysql存储过程中的变量查询赋等等问题。。。。。。
sql 代码
- /*
- SQLyog 企业版 - MySQL GUI v5.02
- 主机 - 5.0.27-community-nt : 数据库 - car110
- *********************************************************************
- 服务器版本 : 5.0.27-community-nt
- */
-
-
- /*数据表 `bar_apply_bar` 的表结构*/
-
- CREATE TABLE `bar_apply_bar` (
- `id` int(32) NOT NULL auto_increment,
- `title` varchar(255) NOT NULL,
- `content` text,
- `img_href` varchar(255) default NULL,
- `user_id` int(32) NOT NULL default '0',
- `ip` varchar(15) NOT NULL,
- `state` tinyint(1) NOT NULL default '0' ,
- PRIMARY KEY (`id`)
- ) ;
-
- /*数据表 `bar_apply_bar` 的数据*/
-
- /*数据表 `bar_apply_king` 的表结构*/
-
- CREATE TABLE `bar_apply_king` (
- `id` int(32) NOT NULL auto_increment,
- `bar_id` int(32) NOT NULL,
- `content` text,
- `realName` varchar(50) default NULL,
- `tel` varchar(50) default NULL,
- `email` varchar(100) default NULL,
- `state` tinyint(1) NOT NULL default '0',
- PRIMARY KEY (`id`)
- );
-
- /*数据表 `bar_apply_king` 的数据*/
-
- /*数据表 `bar_bar` 的表结构*/
-
- CREATE TABLE `bar_bar` (
- `id` int(32) NOT NULL auto_increment,
- `title` varchar(50) NOT NULL,
- `subjects` int(16) NOT NULL default '0' ,
- `ties` int(16) NOT NULL default '0' ,
- `pnum` int(16) NOT NULL default '0',
- `sort_id` int(32) NOT NULL,
- PRIMARY KEY (`id`)
- ) ;
-
-
-
- /*数据表 `bar_king` 的表结构*/
-
- CREATE TABLE `bar_king` (
- `id` int(32) NOT NULL auto_increment,
- `user_id` int(32) NOT NULL,
- `bar_id` int(32) NOT NULL,
- PRIMARY KEY (`id`)
- );
-
-
-
- /*数据表 `bar_sort` 的表结构*/
-
- CREATE TABLE `bar_sort` (
- `id` int(32) NOT NULL auto_increment,
- `title` varchar(50) NOT NULL,
- `pnum` int(16) NOT NULL default '0',
- `fid` int(32) NOT NULL default '0' ,
- PRIMARY KEY (`id`)
- );
-
-
-
- /*数据表 `bar_tie` 的表结构*/
-
- CREATE TABLE `bar_tie` (
- `id` int(32) NOT NULL auto_increment,
- `title` varchar(50) NOT NULL,
- `content` text,
- `img_href` varchar(255) default NULL,
- `user_type` tinyint(1) NOT NULL default '0' ,
- `user_id` int(32) NOT NULL,
- `ip` varchar(15) default NULL,
- `itime` timestamp NOT NULL,
- `bar_id` int(32) NOT NULL,
- `clicks` int(32) NOT NULL default '0',
- `reverts` int(32) NOT NULL default '0',
- `top` tinyint(1) NOT NULL default '0' ,
- `jing` tinyint(1) NOT NULL default '0' ,
- `fid` int(32) NOT NULL default '0' ,
- PRIMARY KEY (`id`)
- ) ;
-
-
-
-
-
-
-
-
-
-
-
- /*数据表 `bar_bar` 的触发器结构*/
-
- DELIMITER $$;
-
- DROP TRIGGER `tri_bar_del`$$
-
- CREATE TRIGGER `tri_bar_del` BEFORE DELETE ON `bar_bar` FOR EACH ROWBEGIN
- delete from bar_tie where bar_id=Old.id and fid=0;
- END$$
-
-
- DELIMITER ;$$
-
-
-
-
- /*数据表 `bar_sort` 的触发器结构*/
-
- DELIMITER $$;
-
- DROP TRIGGER `tri_bar_sort_del`$$
-
- CREATE TRIGGER `tri_bar_sort_del` BEFORE DELETE ON `bar_sort` FOR EACH ROWBEGIN
- delete from bar_bar where sort_id=Old.id;
- END$$
-
-
- DELIMITER ;$$
-
-
-
-
- /*数据表 `bar_tie` 的触发器结构*/
-
- DELIMITER $$;
-
- DROP TRIGGER `tri_tie_add`$$
-
- CREATE TRIGGER `tri_tie_add` AFTER INSERT ON `bar_tie` FOR EACH ROWBEGIN
- if New.fid=0 then
- update bar_bar set subjects = subjects+1 where id = New.bar_id;
- end if;
- update bar_bar set ties = ties+1 where id = New.bar_id;
- END$$
-
-
- DELIMITER ;$$
-
-
-
- /*过程 `proc_tie_del` 的过程结构*/
-
- drop procedure if exists `proc_tie_del`;
-
- DELIMITER $$;
-
- CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_tie_del`(IN xid int)
- BEGIN
- declare delrows int;
- if exists (select * from bar_tie where id=xid and fid=0) then
- select count(*) from bar_tie where fid=xid into delrows;
- delete from bar_tie where fid=xid;
- update bar_bar set ties=ties-delrows-1;
- update bar_bar set subjects=subjects-1;
- elseif exists (select * from bar_tie where id=xid) then
- update bar_bar set ties=ties-1;
- end if;
- delete from test where id=xid;
- END$$
-
- DELIMITER ;$$
-
分享到:
相关推荐
网盘文件永久链接 第1讲 初始MySQL 第2讲 MySQL的安装与配置 第3讲 数据库的基本操作 第4讲 数据表的基本操作 第5讲 数据类型和运算符 第6讲 MySQL函数 第7讲 查询数据 ...课本源代码 MySQL常用命令大全
14. **存储过程与触发器**:介绍存储过程和触发器的定义与调用,以及它们在数据库管理和自动化任务中的应用。 15. **事务处理**:理解ACID属性,学习如何使用BEGIN、COMMIT、ROLLBACK语句进行事务控制。 16. **...
下载的`.tar.gz`文件包含了编译和安装MySQL 5.6.15所需的所有源代码和文档。解压后,你需要遵循一系列步骤来编译和配置MySQL,这通常包括配置选项设置、编译、安装以及初始化数据库。在Linux系统中,这些步骤可能...
此外,还增强了对存储过程、触发器和视图等高级数据库功能的支持,使得MySQL更加接近于一个企业级的关系型数据库管理系统。 在"mysql-4.0.5-beta"这个子目录中,我们可以预期找到MySQL服务器的源代码、安装脚本、...
在提供的压缩包中,"MySQL_For_Windows_x64_PChome下载介绍.txt"可能包含关于如何在Windows 64位系统上安装和配置MySQL的指南,"PCHome_download.html"可能是下载页面的源代码或一个链接页面,而"mysql-5.1.73-winx...
MySQL的特征包括性能快捷、优化SQL语言、易于使用、多线程和可靠性、多用户支持、可移植性和开放源代码等。 MySQL的优点 * 数据按一定的数据模型组织、描述和储存 * 可为各种用户共享 * 冗余度较小,节省存储空间 ...
而MySQL则是一款轻量级、开放源代码的数据库系统,因其高效、易用和成本效益而广受开发者喜爱,常用于Web应用程序。 在实战训练营中,学员将学习如何使用SQL进行CRUD操作,即创建(Create)、读取(Retrieve)、更新...
学习Oracle,你需要了解SQL语法、PL/SQL编程、数据库设计、索引、存储过程、触发器、事务管理和数据库备份与恢复等。Oracle还提供了如SQL Developer这样的工具,方便用户进行数据库管理和开发。 再来说说MySQL,它...
Azure Functions 是一种事件驱动的服务,它允许开发者编写只在特定事件触发时执行的代码片段,这些事件可以来自各种源,如云消息、存储队列或 HTTP 请求。Function Apps 是 Azure Functions 的容器,它为多个函数...
5. 存储过程和触发器:讨论存储过程的优点,如何在Visual C++中调用存储过程,并解释触发器在数据库事件中的作用。 6. 数据库事务和安全性:讲解事务的ACID属性(原子性、一致性、隔离性和持久性),以及如何在C++...
1. **多调度器引擎**:它支持三种不同的调度器引擎——基于日期(DateBasedJobStore)、基于内存(MemoryJobStore)和基于数据库(如SQLite、MySQL等)的JobStore。这使得你可以根据应用需求选择最适合的存储方式。 ...