问题标签 [db2-luw]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
1551 浏览

sql - 从多个相同的记录中仅更新 DB2 中的 1 条记录?

我正在尝试更新一条记录,它是另一条记录的精确副本。有没有办法在更新时限制或只选择 1 条记录?

谢谢

0 投票
1 回答
3698 浏览

db2 - IBM DB2 9.7 确定默认表空间

我有一个 DB2 9.7 数据库。我已经定义了任何特定的表空间,所以所有表都转到 USERSPACE1。

现在,我创建了两个新表空间,并使用 IN 子句为这两个新表空间中的每一个分配了两个表。但是,现在所有其他表也都进入了两个新表空间之一,即使我没有为其余的表指定它!

我怎样才能让其余的表转到以前的 USERSPACE1 表空间,而不为每个表显式定义它?谢谢。

0 投票
2 回答
665 浏览

logging - DB2 Suspend Logging

Running DB2 9.7.5 LUW on Windows 2008. I'm transfering data hourly from a MS SQL 2008 server over the WAN. I read the data from MS SQL, parse the data and batch insert into a work table in DB2, then in DB2 merge the data from the work table to the master table. Once the merge is done, I clear the work table to prepare for next load. I've noticed that my log files are very big. Since the db session is open and closed during data exchange, temporary tables are not suitable, hence the use of work tables. The data is transfered by a java app which I made.

I don't need to have the work table transactions logged. I've read this article from IBM and found that logging doesn't happen in the same work unit as when the table was created.

Using CREATE TABLE...NOT LOGGED INITIALLY and ALTER TABLE...NOT LOGGED INITIALLY really work? From what I understand once you have created the table that logging begins after the first commit?

Do I need to create the table everytime with not logged and then clear it with alter table not logged? Is there a better way?

0 投票
1 回答
92 浏览

sql - SELECT 行,同时对前一行作为参数的每一行执行操作

假设我有一张类似的表格:

如何执行SELECT查询以检索行0..N,而不是获取它们的值,而是获取与每一行的前一行的算术差异,即RESULT(N) = ROW(N) - ROW(N-1)?我希望得到类似的东西:

我正在使用DB2. 如果您向我提供一些并非特定于特定 SQL DBMS 的可移植响应,那将非常酷。

提前致谢!

0 投票
1 回答
4629 浏览

sql - 简单删除列 DB2 的问题

我对 DB2 中的简单删除列查询有一个奇怪的问题。我做了一些研究,语法似乎显然是正确的,但我仍然有错误。这是查询:

该表存在,该列也存在(这是一个简单的可为空的 varchar),但我仍然有这个错误:

非法使用关键字列。TOKEN QUERY MATERIALIZED PRIMARY FOREIGN CONSTRAINT RESTRICT UNIQUE WAS EXPECTED SQL Code: -199, SQL State: 42601

我究竟做错了什么?提前致谢。

0 投票
1 回答
6135 浏览

db2 - Roll-forward is required following the Restore

I have three different databases for my different environments (hsprd, hstst,hstrn). hsprd is my production environment with live data.

Every so often, a request comes through to restore production data to hstrn or hstst. I typically run this command (after stopping, then dropping the db):

db2 restore db hsprd taken at 20140331180002 to /dbs into hstrn newlogpath /dbs/log/hstrn without rolling forward;

When running this, I receive this message:

SQL2537N Roll-forward is required following the Restore.

Could someone advise how to fix this?

Thanks.

edit: My backups are here:

After restoring my database and omitting without rolling forward, I receive this message when trying to query the database:

SQL1117N A connection to or activation of database "HSTRN" cannot be made because of ROLL-FORWARD PENDING. SQLSTATE=57019

When I try to rollforward, with this command, I receive this response:

0 投票
1 回答
829 浏览

sql - 根据日期列检索数据,日期列具有空值和非空值

我正在尝试根据实际完成日期和状态从 db2 检索更改请求详细信息,但实际完成日期null没有得到检索状态,怎么会出现

我的条件:

0 投票
1 回答
3614 浏览

java - java.sql.PreparedStatement.setArray() :不支持的交叉转换

当我使用 jdbc 运行以下查询时,出现如下所示的异常。这是一个简化的例子,preparedStatementSetter 和 setString 和 setInt 等其他部分运行成功。

引起:com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10349][11717][4.13.80] 源类型 Object 的不支持交叉转换;。在 com.ibm.db2.jcc.am.id.a(id.java:677) 在 com.ibm.db2.jcc.am.id.a(id.java:60) 的 ERRORCODE=-4461, SQLSTATE=42815在 com.ibm.db2.jcc.am.id.a(id.java:103) 在 com.ibm.db2.jcc.am.ic.a(ic.java:289) 在 com.ibm.db2.jcc .am.ic.a(ic.java:191) 在 com.ibm.db2.jcc.am.kc.a(kc.java:1943) 在 com.ibm.db2.jcc.am.go.a(go .java:2289) 在 com.ibm.db2.jcc.am.go.setArray(go.java:2254) 在 com.jolbox.bonecp.PreparedStatementHandle.setArray(PreparedStatementHandle.java:261) 在 net.sf.log4jdbc。在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

0 投票
6 回答
19136 浏览

db2 - SQL 根据 db2 中的 ID 匹配从一个表更新到另一个表

下面的查询适用于 SQL 服务器。但是在 DB2 中它没有给出结果:

询问:

有人可以澄清 b/w DB2 和 SQL 查询的区别吗?

0 投票
1 回答
167 浏览

db2 - where 子句 select 语句中的条件运算符在 DB2 中不返回数据?

下面的语句在 DB2 命令行上对我不起作用?AMOUNT 是表中类型为 DOUBLE 的列。我的查询好吗?