【问题标题】:Change Table names in derby database using entitymanager使用 entitymanager 更改 derby 数据库中的表名称
【发布时间】:2013-09-21 08:31:54
【问题描述】:

我正在使用 APACHE DERBY 数据库,并且我的数据库交互基于 EntityManager,我不想使用 JDBC 类来构建查询来更改我的表的名称(我只需要为每个新的用户到应用程序,但具有相同的表结构),例如:

//em stands for EntityManager object
Query tableNamesQuery= em.createNamedQuery("RENAME TABLE SCHEMA.EMP_ACT TO EMPLOYEE_ACT");
em.executeUpdate();
// ... rest of the function's work
// The command works from the database command prompt but i don't know how to use it in a program
//Or as i know you can't change system tables data, but here's the code
Query tableNamesQuery= em.createNamedQuery("UPDATE SYS.SYSTABLES SET TABLENAME='NEW_TABLE_NAME' WHERE TABLETYPE='T'");
em.executeUpdate();
// ... rest of the function's work

我的问题是:

  • 这个语法正确吗?
  • 它会起作用吗?
  • 还有其他选择吗?
  • 我是否应该只使用 SYS.SYSTABLES 并找到所有表类型为“T”的表并更改它们的名称,是否会更改访问名称?

【问题讨论】:

    标签: java rename derby entitymanager


    【解决方案1】:

    我认为您正在寻找 RENAME TABLE 语句:http://db.apache.org/derby/docs/10.10/ref/rrefsqljrenametablestatement.html

    不要只针对系统目录发出更新语句,您会损坏您的数据库。

    【讨论】:

      猜你喜欢
      • 2013-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-13
      • 1970-01-01
      • 2013-11-17
      • 2011-01-19
      相关资源
      最近更新 更多