SQLite 在触发器上创建表 [英] SQLite create table on trigger

查看:53
本文介绍了SQLite 在触发器上创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为插入到现有表中的每一行创建一个新表.

I want to create a new table for every row that is inserted into an existing table.

据我所知,触发器上只允许进行 DML 操作,是否正确.如果是这样,是否有其他方法可以实现我的目标?

As I understand only DML operation is allowed on trigger, is it correct. If so is there a alternative way of achieving my objective?

推荐答案

SQLite 确实只允许在触发器主体中使用 DML.

SQLite indeed allows only DML in a trigger body.

但是,您可以使用 用户定义的函数 执行 SELECT,然后执行另一个创建表的 SQL 命令:

However, you could do a SELECT with a user-defined function that then executes another SQL command to create the table:

CREATE TRIGGER ...
...
BEGIN
    SELECT my_create_table_function(NEW.name);
END;

这篇关于SQLite 在触发器上创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆