728x90

MATCHES and LIKE in SQL conditions

Informix supports MATCHES and LIKE in SQL statements, while ORACLE supports the LIKE statement only.

 

MATCHES allows you to use brackets to specify a set of matching characters at a given position:

( col MATCHES '[Pp]aris' ).
( col MATCHES '[0-9][a-z]*' ).

 

In this case, the LIKE statement has no equivalent feature.

 

The following substitutions must be done to convert a MATCHES condition to a LIKE condition:

  • MATCHES keyword must be replaced by LIKE.
  • All '*' characters must be replaced by '%'.
  • All '?' characters must be replaced by '_'.
  • Remove all brackets expressions.

Solution

SQL statements using MATCHES expressions must be reviewed in order to use LIKE expressions.

ORACLE provides the TRANSLATE function which can be used to replace MATCHES in specific cases. The TRANSLATE function replaces all occurrences of characters listed in a 'from' set, with the corresponding character defined in a 'to' set.

Informix: WHERE col MATCHES'[0-9][0-9][0-9]'
ORACLE: WHERE TRANSLATE(col,'0123456789','9999999999')='999'

 

출처 : IBM Informix Genero Business Development Language User Guide, v2.41 (SC27-3852-01)

728x90
728x90

LOCKS Configuration Parameter


The LOCKS configuration parameter specifies the initial size of the lock table.

The lock table holds an entry for each lock. If the number of locks allocated exceeds the value of the LOCKS configuration parameter, the database server increases the size of the lock table. The lock table can be increased a maximum of 99 times.

onconfig.std value
20000
units
Number of locks in the internal lock table
range of values
2,000 through 8,000,000 for 32-bit database servers 2,000 through 500,000,000 for 64-bit database servers
takes effect
When the database server is shut down and restarted
utilities
onstat -k (see onstat -k command: Print active lock information.)
refer to
  • The memory and locking chapters in your IBM® Informix® Performance Guide
  • The shared memory chapter in the IBM Informix Administrator's Guide

The database server increases the size of the lock table by attempting to double the lock table on each increase. However, the amount added during each increase is limited to a maximum value. For 32-bit platforms, a maximum of 100,000 locks can be added during each increase. Therefore, the total maximum locks allowed for 32-bit platforms is 8,000,000 (maximum number of starting locks) + (99 (maximum number of dynamic lock table extensions) x 100,000 (maximum number of locks added per lock table extension). For 64-bit platforms, a maximum of 1,000,000 locks can be added during each increase. Therefore, the total maximum locks allowed is 500,000,000 (maximum number of starting locks) + (99 (maximum number of dynamic lock table extensions) x 1,000,000 (maximum number of locks added per lock table extension).

With the initial lock table stored in resident memory and each additional lock stored in virtual memory, locks can become a resource drain if you have a limited amount of shared memory. The amount of storage occupied by a single lock depends on the word size and operating system, and is subject to change. Currently, the amount of storage ranges from approximately 100 to 200 bytes. You can see the amount of storage required to support additional locks by restarting the server with a different value of the LOCKS configuration parameter (without making other changes), and observing the increase in memory used as shown by onstat -g mem" for the resident pool.


저만큼 크게 잡은 데를 본적은 없다. 10점대와 비교하면 증가하는 횟수에 차이가 있다


http://publib.boulder.ibm.com/infocenter/idshelp/v115/index.jsp?topic=%2Fcom.ibm.adref.doc%2Fids_adr_0094.htm&resultof="locks"%20

http://www.ibm.com/developerworks/data/library/techarticle/dm-0701herber/index.html

728x90
728x90

인포믹스에서 오라클의 Built-in 함수 greatest 구현

함수 인자의 데이터 타입과 갯수에 따라 SPECIFIC을 지정하여 작성한다.


CREATE FUNCTION GREATEST (P1 INT, P2 INT)

RETURNING INT SPECIFIC GREATESTInt2

CASE

WHEN P1 >= P2 THEN P1

ELSE               P2

END FUNCTION;


http://www.ibm.com/developerworks/data/library/samples/db2/0205udfs/index.html

728x90
728x90

IBM Data Server Driver for JDBC and SQLJ type 4 connectivity URL syntax

Read syntax diagramSkip visual syntax diagram
>>-+-jdbc:db2:------+--//--server--+---------+--/--database----->
   +-jdbc:db2j:net:-+              '-:--port-'                
   '-jdbc:ids:------'                                         
>--+------------------------------+----------------------------><
   |    .-----------------------. |   
   |    V                       | |   
   '-:----property--=--value--;-+-'   

jdbc:ids:
Indicates that the connection is to an IBM Informix data source. jdbc:informix-sqli: also indicates that the connection is to an IBM Informix data source, but jdbc:ids: should be used.
1. jdbc 드라이버 인스톨
db2jcc.jar, db2jcc_license_cu.jar
2. jdbc 드라이버 클래스
com.ibm.db2.jcc.DB2Driver
3. String url
String url = "jdbc:ids://myhost:1533/stores_demo";

http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.apdv.java.doc/src/tpc/imjcc_c0024189.html

728x90
728x90

You can use the double colon operator (::) to cast GeoTimeRange values to a specific precision. This allows you to specify a less precise input specification than the GL_DATETIME setting. It does not, however, override the GL_DATETIME setting, nor does it extend text input.

In the following example, GL_DATETIME is set to YEAR TO DAY, and the DATETIME cast allows you to specify a GeoTimeRange value with a precision less than the minimum default of YEAR TO SECOND:

-- GL_DATETIME="%Y-%m-%d"
INSERT INTO trtab VALUES (GeoTimeRange('1997-01-02'::datetime year to day));
SELECT * FROM trtab;
tr  (1997-01-02,1997-01-02) 

In the following example, the cast allows you to specify less than the GL_DATETIME precision:

-- GL_DATETIME="%Y-%m-%d %H:%M:%S"
INSERT INTO trtab VALUES (GeoTimeRange('1997-01-02'::datetime year to day));
SELECT * FROM trtab;
tr  (1997-01-02 00:00:00,1997-01-02 00:00:00) 

The data, however, is zero-extended on input and output to YEAR TO SECOND.

Tip:
Instead of casting, you could insert data with hours, minutes, and seconds set to 0 (or any value). The hours, minutes, and seconds would be truncated to conform to the GL_DATETIME setting of YEAR TO DAY.

In the following example, the INSERT statement returns an error message because the cast is to YEAR TO DAY, while YEAR TO SECOND data is inserted:

-- GL_DATETIME="%Y-%m-%d %H:%M:%S"
INSERT INTO trtab VALUES (GeoTimeRange('1997-01-02 03:04:05'::datetime year to day));
SELECT * FROM trtab;
 1264: Extra characters at the end of a datetime or interval.


http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.geod.doc/geod55.htm

728x90
728x90

Question

What do you need to know to set up multi-byte or different locale databases in IBM Informix Servers?

Cause

You currently have a typical en_us (US English) database, which is a normal, default style database with no extra intervention needed for the setup. You want to expand your company database into another country and use a multi-byte character set, or a different locale for the database. What is needed for the setup?

Answer

There are several issues to consider when setting up a database with a locale which is non-US. Here is an overview of the considerations, which are discussed below:

  1. An understanding of code-sets and their impact on a database.
  2. An understanding of default vs nondefault locale code-sets.
  3. Unicode vs language code-set usage

Code-sets and their impact

An ASCII code-set is based on 128 printable characters that occupy 7 bits of a single byte representation. Some characters encoded in other languages can not be represented by a single byte value. one example of a multibyte code-set is the Japanese code set known as Kanji. The technical name is SJIS (ja_jp.sjis). It is a multibyte code-set, with characters that are encoded in 2 or 3 bytes. Some code-sets can have up to 4 bytes to represent a printable character. There are several issues to consider in using any code-set:


Default vs nondefault Code-sets

A default code-set is relative to the language base in which is is used. Some languages have the same letter characters as English, but they also have character variations. The character variations cause the result that some code-sets are nondefault.. Some considerations for default and nondefault code-sets:


Code-set installation and setupIBM Informix GLS User's Guide, available here:http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp?topic=/com.ibm.glsug.doc/glsug02.htm
See also:
Esql/c Programmers Guide, available here:
http://publib.boulder.ibm.com/infocenter/idshelp/v117/index.jsp?topic=/com.ibm.esqlc.doc/esqlc.htm


http://www-01.ibm.com/support/docview.wss?uid=swg21449292&myns=swgimgmt&mynp=OCSSGU8G&mync=E

728x90
728x90

Question

How to set an optimal physical log size in IDS11.5 versions.

Cause

Transactions are able to continue working during checkpoints. To avoid blocked transactions,the database server must have enough physical log space to contain all of the transaction activity that occurs during checkpoint processing. Checkpoints can be triggered when the physical log is 75 percent full and checkpoint processing must complete before the remaining 25 percent of the physical log is used. Transaction blocking occurs as soon as the system detects a potential for a physical log overflow, because every active transaction could generate physical log activity.


Answer

The optimal size of the physical log depends on two factors:

1.The rate at which transactions generate physical log activity.

[1]Buffer Pool Space less than 4G.
For systems with less that four gigabytes of buffer pool space, the physical log can
be sized at 110 percent of the combined size of all the buffer pools.

[2]For larger buffer pools (Commonly larger than 4G)
Start with four gigabytes of physical log space and then monitor checkpoint activity. If checkpoints occur too frequently and appear to impact performance, increase the physical log size,and look into the Trigger column of the onstat -g ckp output. If the trigger events occur frequently by PLOG, then increase the size of the physical log.

2.Whether or not you set the RTO_SERVER_RESTART configuration parameter.

If RTO_SERVER_RESTART is enabled, the physical log size must be less than all buffer pools to maintain the RTO_SERVER_RESTART policy.


http://www-01.ibm.com/support/docview.wss?uid=swg21443076

728x90
728x90

Problem(Abstract)

This article presents a method of preventing the startup of the scheduler threads during IDS server initialization

Resolving the problem

INTRODUCTION

The Scheduler is a component of IBM Informix® Dynamic Server™ (IDS) that executes tasks defined in the sysadmin database. These tasks are coordinated by the dbScheduler and dbWorker threads within the server. There may be occasions when it is required to prevent the startup of these threads, for example if an assert failure occurs during initialization of the server. This article describes a method to temporarily prevent the startup of the threads used by the Scheduler.


STEPS

  1. As the root or informix user create the empty file $INFORMIXDIR/etc/sysadmin/stop. one way to do this is to use the Unix command touch.
  2. Stop and restart IDS.
  3. During initialization the following message will appear in the message log:
    SCHAPI: "INFORMIXDIR/etc/sysadmin/stop" file is present.
    Bypassing dbScheduler and dbWorker threads startup.

Important: If the reason for preventing the startup of the Scheduler threads was due to an error such as assert failure then that problem may still exist when the Scheduler is restarted. This document describes a temporary workaround and not a solution to this type of problem and you should search for other documents that refer to this topic for a solution.



http://www-01.ibm.com/support/docview.wss?uid=swg21260058

728x90
728x90

Problem(Abstract)

This document is a comparison of High Performance Loader's Express and Deluxe Mode Load jobs.

Resolving the problem

High Performance Loader: Mode Comparison for Load Jobs

Express Mode​
Deluxe Mode​
Not logged​Logged​
Constraints, Indexes, Triggers DISABLED until job completes​Constraints set to FILTERING WITHOUT ERROR​
Indexes checked​
Triggers evaluated​
Table is exclusively locked for duration of the load​Table not locked​
Transaction level is a single transaction​Transaction Level defined by commit interval​
Loaded data not immediately available until table is unlocked and constraints enabled​Loaded data immediately available​
Limitations: ​Limitations: ​
Performance Considerations: ​Performance Considerations: ​


http://www-01.ibm.com/support/docview.wss?rs=0&uid=swg21051331

728x90
728x90

Problem(Abstract)

This article describes a problem which occurs when constraints and their related indexes are created and named by the default system commands, and a way to name them manually.

Resolving the problem

PROBLEM

Depending upon how you create primary/foreign key constraints, IDS will generate names for them and the indexes that are used to enforce them. These names are not intuitive (like customer_pkind, customer_fk1), which causes confusion when viewing or dropping them.

    Example:

    If you create a table like this:

    create table customer
          ( customer_num            serial(101),
            fname                   char(15),
            lname                   char(15),
            company                 char(20),
            address                 char(200),
            phone                   char(18),
           primary key (customer_num)
          );

    Then you will end up with an index called ' 100_1' (note the leading space), and the constraint name is 'u100_1'. These names are generated based on the tabid (customer is tabid 100) and a sequence number. The index can't be dropped directly, because the name has a leading space character.


    Adding a primary key after creating the table (with alter table) hits the same generated name issue:

      alter table customer add constraint primary key (customer_num) ;

    The index name is now ' 100_26' and the constraint name is 'u100_26'.



CAUSE

The program is designed to work this way.



SOLUTION

To remove the index you have to look up the constraint name, either through dbaccess:

Query Language <Select the database > Info  <Select  the table>  
           cOnstraints Primary / Reference


or with SQL like this:

  select t.tabname, i.idxname, i.idxtype, 
         c.constrname, c.constrtype
    from systables t, sysindexes i, sysconstraints c
   where t.tabtype = 'T'
     and t.tabid = i.tabid
     and i.idxname = c.idxname
     -- and t.tabname = 'TABLENAME'
  order by 1, 2  ;


and then drop the constraint:

  alter table customer drop constraint u100_1 ;



HOW TO AVOID THIS PROBLEM

You can set the constraint name of your choice by adding a constraint naming clause to the ALTER TABLE or CREATE TABLE command:

    Example:

    alter table customer add constraint 
    primary key (customer_num) constraint cust_pk ;

    create table customer
          ( customer_num            serial(101),
            fname                   char(15),
            lname                   char(15),
            company                 char(20),
            address                 char(200),
            phone                   char(18),
           primary key (customer_num) constraint cust_pk
          );

This sets the constraint name to 'cust_pk', but the index name is still generated (to ' 100_27' or similar). 

To control the index name, you must create the index before the constraint.

    Example:
    create unique index cust_pki on customer(customer_num) ;
    alter table customer add constraint
      primary key (customer_num) constraint cust_pkc ;


This way the index name becomes 'cust_pki', and the constraint name is 'cust_pkc' (though it is more common to set them to the same name).

When you create a constraint, it will use an existing index instead of creating one, if one exists with the right columns in the right order and the right uniqueness.

Creating the index explicitly first also means you can specify which dbspace(s) it is stored in, the fill factor, and other things.


http://www-01.ibm.com/support/docview.wss?uid=swg21255132

728x90

+ Recent posts