db2-luw

IBM DB2: Generate list of dates between two dates

只谈情不闲聊 提交于 2019-12-19 03:38:11
问题 I need a query which will output a list of dates between two given dates. For example, if my start date is 23/02/2016 and end date is 02/03/2016, I am expecting the following output: Date ---- 23/02/2016 24/02/2016 25/02/2016 26/02/2016 27/02/2016 28/02/2016 29/02/2016 01/03/2016 02/03/2016 Also, I need the above using SQL only (without the use of 'WITH' statement or tables). Please help. 回答1: I am using ,ostly DB2 for iSeries, so I will give you an SQL only solution that works on it.

DB2 Create Table X when X is a variable?

你离开我真会死。 提交于 2019-12-13 07:25:14
问题 In Oracle, we do this: def TNAME=&1 create table &TNAME (foo varchar(10)); How to do the equivalent for DB2? The constraints are: 1. The create table statement is generated when TNAME is unknown 2. The create table statement is in a file which cannot be modified 3. Cannot create a temporary file with TNAME substituted by awk 4. Essentially we want to pass in the table name at run time as an argument Possible? 回答1: The EXECUTE IMMEDIATE statement can be used in just about any block of SQL that

DB2 Size of Table

半世苍凉 提交于 2019-12-13 04:47:04
问题 I'm trying to figure out the size in kb of each table in a schema. I have a query set up, but I'm not sure if I'm getting the correct output. I'm running DB2 v9 LUW. My Query: SELECT T.TABNAME, T.TABSCHEMA, COLCOUNT, TYPE, (DATA_OBJECT_P_SIZE + INDEX_OBJECT_P_SIZE + LONG_OBJECT_P_SIZE + LOB_OBJECT_P_SIZE + XML_OBJECT_P_SIZE) AS TOTAL_SIZE FROM SYSCAT.TABLES AS T, SYSIBMADM.ADMINTABINFO AS A WHERE T.TABNAME = A.TABNAME It works and all, but I am fairly sure that division is required in this

Refer to table name dynamically in DB2/400 SQL query..?

孤者浪人 提交于 2019-12-13 04:41:16
问题 I'd like to run a query that gets a combination of live data and metadata for a regularly changing list of table names. This is for research & analysis on a large server with 100+ schemas and thousands of tables/views in each. I need help referring to table names dynamically, which I do understand is NOT possible. However... My googling indicates the solution may be an SQL statement in a text variable, which is then executed by the EXEC statement. But this is DB2/400 v7r3, which is a complex

DB2 LUW 10.5 - How to force DB2 Stored procedures to use latest stats for most optimized plan

久未见 提交于 2019-12-13 03:07:19
问题 We see an issue occasionally. Stored procedure running a SQL runs very slow. Same SQL when run from command line runs very fast. It seems stored procedure uses a different path. The workaround for us is to drop and recreate the procedure, after which it picks up the right plan. Is there a way to execute a stored procedure with an instruction to regenerate execution plan at run time, so as to get the best plan every time. 回答1: You probably don't want to recompile plans every time you call your

License ERROR with DB2 driver on linux

℡╲_俬逩灬. 提交于 2019-12-12 17:27:11
问题 Im trying to connect to a DB2 db. ive installed driver server package from IBM 10.5. When i try to connect to the db2 server im receiving that message: [IBM][CLI Driver] SQL1598N An attempt to connect to the database server failed because of a licensing problem. SQLSTATE=42968 SQLCODE=-1598 How can i solve this problem? Im looking for inf on google and i cant see anything to help me. The driver server package has been installed on debian machine to use with php/apache2 server. Thanks! 回答1: Do

How does the HEXTORAW() function work? What is the algorithm?

筅森魡賤 提交于 2019-12-12 09:55:31
问题 HEXTORAW is a function found in several RDBMS's like Oracle, and DB2 on LUW. It takes a character, or integer input, and basically casts it to a HEX value. HEXTORAW(1234) = x'1234' What is the algorithm for this type conversion? What is happening in the code behind the scenes? (This is motivated by wanting to create this function in an RDBMS that does not have the HEXTORAW function.) 回答1: From this page: http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm#i46018 When

SQL5193N The current session user does not have usage privilege on any enabled workloads

南笙酒味 提交于 2019-12-12 06:30:42
问题 I'm getting the error while querying DB2 database 'SQL5193N The current session user does not have usage privilege on any enabled workloads' How should I check if a user has usage permission on workloads? 回答1: To granting the USAGE privilege on a workload. You can use; http://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.admin.wlm.doc/doc/t0051489.html To check whether the user has DBADM authority: db2 "SELECT DISTINCT GRANTEETYPE, GRANTEE, DBADMAUTH from SYSCAT.DBAUTH" To

DB2 linking schemas across multiple instances

戏子无情 提交于 2019-12-12 06:27:06
问题 I have a few instances of DB2 10.5 server running on one physical Linux machine, let name them INST1 and INST2. All of them contain multiple schemas, however schema-naming is unique accross whole machine, for example INST1_SCHEMA_A, INST2_SCHEMA_A etc. What I would like to do is to somehow create a user that can access all of those schemas as they were on one instance, so it would be possible to make a queries like: SELECT ID FROM INST1_SCHEMA_A UNION SELECT ID FROM INST2_SCHEMA_A How can I

IBM Db2 data server client install fails

微笑、不失礼 提交于 2019-12-12 01:24:24
问题 With reference to to A Client for IBM DB2 7.2 AIX I'm trying to install the windows Db2 client: DB2-winx64-client-9.1.1200.483-FP012 (see: http://www-01.ibm.com/support/docview.wss?uid=swg24033024).This fails because it detected previous level of Db2 products installed but it can not determine where is what installed (I don't know what should be uninstalled). I tried to check the log files but they dont give me a clue: === Logging started: 16-2-2017 16:00:26 === Action 16:00:26: INSTALL.