首页 \ 问答 \ 如何使用触发器在MySQL表中插入更改(How To Use Triggers to insert Changes in MySQL tables)

如何使用触发器在MySQL表中插入更改(How To Use Triggers to insert Changes in MySQL tables)

我想创建触发器,我需要执行以下操作。

当编辑表中的记录触发器时,会自动将此更改记录到另一个名为logs的表中,并在我的php脚本中使用它。日志表的设置如下:

编辑表后的值之前的日期时间值*我是触发器的新功能请帮助我我的项目


i want to create triggers and i have a requirement to do the following.

When a record in a tables is edited trigger that will automatically log this change to another table called logs and where it use inside my php script The set up of the log table will be as follows:

date time value before value after edited table * i am new for triggers please help me my project


原文:https://stackoverflow.com/questions/13705237
更新时间:2022-10-25 18:10

最满意答案

就速度而言,本地堆栈分配操作几乎总是胜过动态内存分配。 原因是,在动态内存分配过程中,程序需要向操作系统寻求帮助。 这会导致上下文切换(这非常缓慢/昂贵),并阻塞,直到操作系统返回一块内存(它甚至可能无法)。

然而,你的程序已经拥有了自己的堆栈,所以它可以在不中断执行流程的情况下(不管多任务无法控制)控制它。

动态内存分配的好处是,有时我们不知道需要分配多少,直到运行时为止。 如果没有动态分配,我们需要预先分配一个静态缓冲区,并为最坏情况预留足够的内存(我们可能有或没有足够的资源)。


Local, stack-allocated operations will pretty much always trump dynamic memory allocation in terms of speed. The reason being that, during dynamic memory allocation, your program needs to ask the operating system for help. This causes a context switch (which are very slow/expensive), and blocks until the operating system returns you a block of memory (which it may not even be able to).

Your program however, has its own stack already, and so it can manipulate that as necessary without interrupting the flow of execution (other than multi-tasking which is out of your control anyway).

The benefits to dynamic memory allocation are that sometimes we do not know how much we need to allocate until runtime. Without dynamic allocation, we would need to allocate a static buffer upfront, and reserve enough memory for the worst-case scenario (which we may or may not have enough resources for).

相关问答

更多
  • 您正在使用支持可变长度数组的非标准编译器。 你的教授是对的, int array[size]不应该编译。 你的教授也是 错误 告诉你使用p = new int[size] 。 他应该做的是告诉你使用std::vector p(size) 。 (好吧,出于教育目的,这没关系):) You're using a non-standard compiler, that supports variable length arrays. Your professor is right, int array[ ...
  • 就速度而言,本地堆栈分配操作几乎总是胜过动态内存分配。 原因是,在动态内存分配过程中,程序需要向操作系统寻求帮助。 这会导致上下文切换(这非常缓慢/昂贵),并阻塞,直到操作系统返回一块内存(它甚至可能无法)。 然而,你的程序已经拥有了自己的堆栈,所以它可以在不中断执行流程的情况下(不管多任务无法控制)控制它。 动态内存分配的好处是,有时我们不知道需要分配多少,直到运行时为止。 如果没有动态分配,我们需要预先分配一个静态缓冲区,并为最坏情况预留足够的内存(我们可能有或没有足够的资源)。 Local, stac ...
  • 频繁的分配和释放可能导致内存碎片。 我的猜测是,当您使用调试器逐步执行程序时,它会为操作系统提供空闲时间来对内存进行碎片整理。 为了避免在正常运行程序时出现问题,您应该考虑内存/对象池(请参阅此处和此处 )。 Frequent allocation and deallocation can lead to memory fragmentation. My guess is that, when you step through the program with a debugger, it gives th ...
  • 这是应该发生的事情: 代码1:任何地方都没有储存。 代码2: a存储在堆栈中。 它不存储在.data 。 代码3a可以存储在堆栈中,也可以存储在.rodata ,具体取决于它是否使用常量表达式进行初始化。 优化器也可能决定将其存储在.text (与代码一起)。 我没有看到3个代码之间的数据段有任何不同。 那是因为应该没有区别。 .data用于具有静态存储持续时间的非常量变量,它们被初始化为非零值。 This is what should happen: Code 1: nothing is stored a ...
  • 如果您使用手动内存管理 ,则会出错。 Apple在“ 高级内存管理编程指南 ”中记录了“避免导致重新分配您正在使用的对象”下的问题。 具体来说, objectAtIndex:不会retain并autorelease它返回给您的对象。 因此, NSArray可能只拥有对象的“拥有”引用。 在手动保留计数(MRC)下分配给tmp不保留对象,因此tmp不拥有它,并且自动释放池不拥有它。 这意味着当您的方法的第2行发送[self replaceObjectAtIndex:index1 withObject:[sel ...
  • malloc 函数返回一块连续的内存,就是这样。 如何键入和使用它(对你的对象)是你的问题。 而new 运算符返回在内存中分配的对象。 虽然两者都返回一个指针,但最终你得到了构造的对象,而不是C ++中的原始内存。 在这里,重点从低级内存处理转移到类型安全的对象处理。 这就是new不返回void*的原因。 另外,如果您注意到,在前一种情况下,C,它是一个执行分配的函数,即语言本身没有分配对象或内存的概念。 在C ++中, new是一个运算符,因此该语言本身就能理解动态创建对象的含义。 编译器实现了语言所要求 ...
  • 只要您使用内存分配运行时链接到共享的MSVC库,这就可以工作。 然后EXE和DLL共享同一个堆。 如果您破坏了此依赖关系,则将不再共享堆,并且删除不同堆中的对象将破坏应用程序。 That works as long as you link to shared MSVC libraries with the memory allocation runtime. Then EXE and DLL share the same heap. If you break this dependency, the hea ...
  • 原始VM规范实际上是关于局部变量的,每个局部变量在堆栈上重新设置一个“槽”(只是一个索引号),每个槽应该保存4个字节。 因此每个变量都映射到一个“槽”。 但是占用超过4个字节(双倍,长度)的变量需要占用两个连续的时隙。 但是,引用占用一个插槽 ,尽管它们在64位VM上可能是8个字节。 指定时没有64位VM,因此规范假定32位引用。 在实践中,我非常确定当前的VM会重新映射堆栈插槽,因为它认为合适,并且堆栈上保留的实际大小也将由VM决定。 所以剩下的就是字节码中一个特殊的时隙分配方案,所有实际的“时隙”内容纯 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)