【发布时间】: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