如何在 Mysql 中动态创建一个 table 并以 main table 字段作为其名称?

How to create a table dynamically with a field of main table as its name in Mysql?

我有一个主要的 table 即以 eventid 作为其属性之一的事件。需要的是,无论何时将 eventid 添加为 eventid 的字段,我都需要动态创建一个新的 table 并将字段条目作为新的 table name.Also 我对每个 name.Also 都有类似的列=23=] 将要创建。

比如我输入了abc126作为eventid,我需要创建一个名为abc126的table,并且有

等属性
Username, Password, Fullname, Addresses, contact, etc..

此处每个 table 创建的属性应该相同。

I.e 如果我将另一个 eventid 添加为 xyz222,则应使用上述属性创建一个 xyz222 table。我该怎么做?

每当您在事件 table 中插入一条记录,其中包含 'abc126' 之类的值作为 eventid,

像这样简单地执行下一个查询

CREATE TABLE `abc126` LIKE `events`;

这将创建一个新的 table 作为 'abc126',structure/attributes 类似于您的活动 table。 如果您希望属性与任何其他 table 相似,请将 events 更改为该 table 名称

CREATE TABLE `abc126` LIKE `tablename`;

如果您想进一步修改正在创建的具有有限属性的新 table,请检查 mysql 'CREATE TABLE' 选项。