<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-25  評論-6  文章-0  trackbacks-0
      2006年12月28日

    Question:
    The restore command works fine, but while attempting the rolforward of the sql logs, it complains about database falling short on bufferpool,and then terminates the rollforward process. One close look at the db2diag.log file, I noticed that db2 tried to start the database with the hidden bufferpool. But, apparently, that hidden bufferpool was pretty small to rollforward the logs and bring it online.

    I cannot reduce the bufferpool size as the database cannot be connected to.I cannot connect to the database as it is in rollforward pending state. I cannot rollforward the database, as it's not happy with the size of the *hidden* bufferpool and terminates.

    Answer:

    db2set DB2_OVERRIDE_BPF=50000

    This will bring up all configured bufferpools using 50000 pages each. You
    can choose a smaller/larger value that is suitable for your number of
    bufferpools and available system memory. You can also configure each
    bufferpool individually if you want

    値: 正數のページ數
    ???? OR
    ?<entry>[;<entry>...] (<entry>=<バッファー?プール ID>,<ページ數> )

    There is sitiuation that above solution does not work.

    				When you try to create a bufferpool or alter a bufferpool to a
    very large size and there is not enough memory in the system
    , DB2 may occupies all pagespace and overrall performance of
    the system become slow and may get hang at last because no
    pagespace is available. Then after you connect the database
    next time, DB2 will do crash recovery and still try to
    allocate memory for this big bufferpool and occupy all
    pagespace again. when you specify DB2_OVERRIDE_BPF parameter
    to override bufferpool size, it doesn't take effect in this
    situation. This is becasue DB2_OVERRIDE_BPF only applies for
    bufferpools that already exist at startup, and not to
    bufferpools that are created during crash recovery or roll
    forward. We will fix this problem and check DB2_OVERRIDE_BPF
    registry when creating bufferpools during crash recovery or
    roll forward. This problem only occurs in a 64 bit instance.
    
    		

    Local fix

    				You can use db2iupdt -w 32 <INSTNAME> to update the instance to
    a 32 bit instance, then you can connect to the database
    succefully. After that, use db2iupdt -w 64 <INSTNAME> to update
    the instance to 64 bit again. Please take a backup at this
    point, so we don't have to roll forward through bufferpool
    creation that fails if we need restore and roll forward
    database.
    
    		

    Problem summary

    				Users Affected:
    All users using 64 bit instance
    Problem Description:
    When you try to create a bufferpool or alter a bufferpool to a
    very large size and there is not enough memory in the system
    , DB2 may occupies all pagespace and overrall performance
    of the system become slow and may get hang at last
    because no pagespace is available. Then after you connect the
    database at next time, DB2 will do crash recovery and still try
    to allocate
    memory for this big bufferpool and occupy all pagespace again.
    In this situation, when you specify DB2_OVERRIDE_BPF parameter
    to override bufferpool size, it doesn't take effect in this
    situation. This
    is becasue DB2_OVERRIDE_BPF only applies for bufferpools that
    already exist at startup, and not to bufferpools that are
    created during crash recovery or roll forward. We will fix
    this problem and check
    DB2_OVERRIDE_BPF registry when creating bufferpools during crash
    recovery or roll forward. This problem only occurs in 64 bit
    instance.
    Problem Summary:
    This problem is caused by a misoperation, when you create or alt
    er a bufferpool, the size is too large to allocated from OS and
    cause overrall performance of the system is very slow and seems
    hang. Another problem is that DB2_OVERRIDE_BPF registry only app
    lies to bufferpools that already exists, and not bufferpools wil
    l be created in crash recovery or roll forward. So DB2 will try
    to create this big bufferpool again when doing crash recovery or
     roll forward. We will fix this problem and check DB2_OVERRIDE_B
    PF registry in our crash recovery and roll forward code.
    
    		

    Problem conclusion

    				
    				
    		

    Temporary fix

    				You can use db2iupdt -w 32 <INSTNAME> to update the instance to
    a 32 bit instance, then you can connect to the database
    succefully. After that, use db2iupdt -w 64 <INSTNAME> to update
    the instance to 64 bit again. Please take a backup at this
    point, so we don't have to roll forward through bufferpool
    creation that fails if we need restore and roll
    forward database.Please also notice that be careful when creati
    ng bufferpool, don't specify a too large value.
    
    		


    posted @ 2007-03-15 15:21 MyJavaWorld 閱讀(741) | 評論 (0)編輯 收藏

    Change db2 password in db2 level

    DB2 depends on operation system level authorization to control DB2 system access.

    In some case, our db2 account only allows to connect to instance or database, but not log on the system. In other words, we are not able to use the account to get a shell on unix or logon locally on windows.

    As usual, when we need to change db2 password, we take action on the system level because it's more frank. But in the case above that we can't get logon, we have to do it on db2 level. There are 2 ways.

    • Use the GUI tool DB2 Configuration Assistance
    • Use the command line tools DB2 CLP or CE

    Using DB2 Configuration Assistance

    Right click on a database name, then choose "Change password".

    CA tool interface

    Note: When more than one databases live in same system, we might share the same account in multi-database. Changing password for one of them will affect all databases in this system. In other words, we don't need to do the change on each database, we could choose any we have privileges on the system.

    Limitation: We are not able to change our password in the case of that we are only allowed to attach to the node but not connect to any database, or we don't get the catalog information for any database in the node.

    For this limitation, it works out with the 2nd way.?

    Using DB2 CLP and CE

    We could use CLP and CE to change password for databases and nodes that we connected or attached to.

    • Change by connecting to database
    C:\> db2 connect to SAMPLE user TEST using OLDPWD new NEWPWD confirm NEWPWD
    C:\> db2 connect to SAMPLE user TEST using OLDPWD change password
    • Change by attaching to node, this way works out for the limitation in Configuration Assistance
    C:\> db2 attach to NODE user TEST using OLDPWD new NEWPWD confirm NEWPWD
    C:\> db2 attach to NODE user TEST using OLDPWD change password


    alter table xxx VOLATILE

    valatile

    • a. 反復無常的,揮發性的

    VOLATILE CARDINALITY or NOT VOLATILE CARDINALITY
    Indicates to the optimizer whether or not the cardinality of table table-name can
    vary significantly at run time. Volatility applies to the number of rows in the
    table, not to the table itself. CARDINALITY is an optional keyword. The default
    is NOT VOLATILE.

    VOLATILE
    Specifies that the cardinality of table table-name can vary significantly at
    run time, from empty to large. To access the table, the optimizer will use
    an index scan (rather than a table scan, regardless of the statistics) if that
    index is index-only (all referenced columns are in the index), or that index
    is able to apply a predicate in the index scan. The list prefetch access method
    will not be used to access the table. If the table is a typed table, this option
    is only supported on the root table of the typed table hierarchy (SQLSTATE 428DR).

    NOT VOLATILE
    Specifies that the cardinality of table-name is not volatile.
    Access plans to this table will continue to be based on existing statistics and
    on the current optimization level.

    NOTE: The keyword could be specified within ALTER TABLE, but not CREATE TABLE.

    ?

    Difference between Local and System Database Directory

    DB2 automatically catalogs databases when they are created. It catalogs an entry
    for the database in the local database directory and another entry in the system
    database directory. If the database is created from a remote client (or a client which
    is executing from a different instance on the same machine), an entry is also made
    in the system database directory at the client instance.

    Databases on the same node as the database manager instance are cataloged as
    indirect entries. Databases on other nodes are cataloged as remote entries.

    List DBs in Local Database Directory

    $ db2 list db directory on /path_to_where_db_created?

    List DBs in System Database Directory

    $ db2 list db directory

    ?

    Illustration of standard tables

    Standard Tables Overview

    Query the status for one specified tablespace?

    As we know, we could issue following command to query status for all of tablespaces in current connected DB.

    $ db2 list tablespaces show detail > /tmp/ts.list

    Then find the status for the tablespaces we concerned.

    Is there's a way to query the status for one specified tablespace?

    My answer is No.?

    1. First, I don't find the related column defination in the table or view:
      • sysibm.systablespaces
      • syscat.tablespaces
    2. Second, I don't think DB2 stores the status flag within syscata tables. The reason is that once a tablespace comes into a special status, it will not be allowed changing any longer(this may also happen on a system catalog tablespace.) that will lead to a conflict on changing the tablespace status flag if stores it within system catalog tables.

    Illustration of the DMS table-space address map

    address map for DMS TS

    DB2 directories and files

    • http://publib.boulder.ibm.com/infocenter/db2luw/v8//topic/com.ibm.db2.udb.doc/admin/c0005420.htm

    Illustration of DB2 architechure and process

    overview for tuning

    Reference

    • http://publib.boulder.ibm.com/infocenter/db2luw/v8//topic/com.ibm.db2.udb.doc/admin/c0005418.htm?

    Tablespaces are put into backup pending after a load

    DB2 sets tablespace as Backup Pending state after loading data into a table in linear logging database(that is, logretain or userexit is on), whatever the load is successful or failed. the reason is that the load process will not write log file. from the begin time of loading to the end time of loading, there will be a blank segment in log file, and the rollforward recovery can Not jump over the blank segment to apply the later log file.

    so database needs a backup after loading to make sure db2 have recovery capicibility.

    it's able to use [COPY YES|NO]? or [NONRECOVERABLE] to prevent tablespace go into Backup Pending state. COPY YES will do the backup automatically after loading, and COPY NO and NONRECOVERABLE will give up this backup that means db2 will be not able to recover the database once an serious error occured.


    繼續閱讀 "Tablespaces are put into backup pending after a load" 的剩余內容

    Come pending when droping Procedures

    Problem Description?

    There's no any response for creating or droping any procedures in DB2. Seems it's pending there, without any error returned. This time UPDATE statement on tables could be issued successfully.

    Check Process

    Check OS disk available

    $ df -kl?

    Check database configure

    db2 => get db cfg |more?

    Check system catalog tablespace?

    db2 => list tablespaces show detail |more
    syscatspace 0x0000?

    Cause?

    It caused by issuing CREATE or DROP statement without COMMIT or ROLLBACK statement in CLP which is in non-Autocommit mode.

    Solution?

    After you issue a COMMIT or a ROLLBACK in the CLP or close it, the pending is gone.

    We must be very careful when we use client in non-Autocommit mode just like CLPs in this case.

    To check the Autocommit mode in CLP issues. Refer to:

    set COMMIT mode in db2 clp

    db2 => list command options

    -c 自動落實 OFF

    More?

    From this point, we could get more. Most of strange things like this(pending there and no error return) are caused by locking.

    In this case, it was only the opertation on procedures being pended, so track on this thread to suppose the syscat tables related with procedures are locked then find the what probably causes it.
    ?

    db2 can not create index on local view

    There's an object called index view since MS SQL Server 2000, it's an index which is created on an view which is based on a local table. it is attent to imporve the select performence on the view when this view is based on multi-table and has complex logic.

    I try to find a simular thing in DB2, but there's no the simular solution in DB2 v8.2 for now. Instead, I found another thing instested.

    DB2 allows creating index on the tables or views in remote data source, such as a database on another host or an XML data source. To be exactly, that's Not true Index, it's Index Specification. It requests that the tables in remote data source have created index in its own system. And it only repeat the index description in local system.

    										Local DB2 Env??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? Remote DB2 Env
    										

    Index Specification??? ->??? Nickname?? - - ->?? True Index??? ->??? Table

    See following example in DB2 info center.

    • CREATE INDEX statement
      http://publib.boulder.ibm.com/infocenter/db2luw/v8//topic/com.ibm.db2.udb.doc/admin/r0000919.htm?resultof=%22%63%72%65%61%74%65%22%20%22%63%72%65%61%74%22%20%22%69%6e%64%65%78%22%20%22%73%74%61%74%65%6d%65%6e%74%22%20

    Example 3:? The nickname EMPLOYEE references a data source table called CURRENT_EMP. After this nickname was created, an index was defined on CURRENT_EMP. The columns chosen for the index key were WORKDEBT and JOB. Create an index specificationindex. Through this specification, the optimizer will know that the index exists and what its key is. With this information, the optimizer can improve its strategy to access the table. that describes this

       CREATE UNIQUE INDEX JOB_BY_DEPT
    ON EMPLOYEE (WORKDEPT, JOB)
    SPECIFICATION ONLY

    Note: the Nickname is only allowed to be created on tables in local database and on much kind of objects at remote data source. It's not allowed to be created on views in local database.

    set COMMIT mode in db2 clp

    As default, DB2 CLP will do commit after you issue each DB2 statements or SQL automatically.

    If you want to change it instead of issuing COMMIT or ROLLBACK manually, do following.

    SQLLIB\BIN> db2
    db2 => list command options
    ??? -c?? ON
    db2 => update command options using c off
    db2 => list command options
    ??? -c?? OFF

    This change will only exists during this session. The setting will lose when you close this CLP and open CLP next time.

    following cmd will get the same result with above.

    SQLLIB\BIN> db2 list command options
    ??? -c??? ON
    SQLLIB\BIN> db2 +c
    db2 =>
    db2 => list command options
    ??? -c??? OFF
    db2 => quit
    SQLLIB\BIN> db2 list command options
    ??? -c??? ON

    There's also the way to keep the settings forever, do following.

    SQLLIB\BIN\> db2 list command options
    ??? -c?? ON
    SQLLIB\BIN\> db2set db2options=+c
    SQLLIB\BIN\> db2 list command options
    ??? -c?? OFF

    This change will take effection immediately even for others having been opened CLP windows. And will keep along.

    Use following cmd set it back to ON.?

    SQLLIB\BIN> db2set db2opptions=-c

    Reference

    表與索引的重命名 RENAME

    在DB2 中重命名表或者索引

    db2=> RENAME TABLE EMP TO EMPLOYEE
    db2=> RENAME TABLE ABC.EMP TO EMPLOYEE
    db2=> RENAME INDEX NEW-IND TO IND
    db2=> RENAME INDEX ABC.NEW-IND TO IND
    posted @ 2007-03-15 15:00 MyJavaWorld 閱讀(529) | 評論 (0)編輯 收藏
    三個UNIX文件時間ctime、mtime、atime
    ?????? 我曾經根據文件的狀態在指定時間內是否改變寫過一個WatchDog來對服務進行監控,其間曾被這三個時間搞混淆,所以覺得很有必要和大家分享我對這三個術語的理解。
    ????? ctime(change time)改變時間:是指文件狀態最后一次被改變的時間;
    ????? mtime(modification time)修改時間:是指文件內容最后一次被改變的時間;
    ????? atime(access time)訪問時間:是指文件最后一次被讀取的時間。
    ????? 前兩者的區別就在于文件狀態的改變既包括文件索引節點的改變,也包括文件內容的改變。也就是說如果你改變了文件內容,則同時更新了ctime和mtime,但是如果你只改變了文件索引節點則只是改變了ctime。atime只有在文件被讀取的時侯才會改變。它的改變與文件狀態以及文件內容的改變沒有直接的聯系。
    ???? 例如:echo “Hello World” >> myfile 則同時改變了ctime和mtime,atime不變;
    ???? chmod u+x myfile 則只改變了ctime,mtime和atime不變。
    ???? cat myfile,則只改變了atime,ctime和mtime不變
    ???? ps:以上操作均在redhat linux下驗證通過
    posted @ 2007-03-13 17:51 MyJavaWorld 閱讀(1175) | 評論 (0)編輯 收藏
    ?
    ?
    查看文章
    ?
    DB2/SQL命令大全
    2006-12-25 13:21

    連接數據庫:

    ??connect?to?[數據庫名]?user?[操作用戶名]?using?[密碼]?

    創建緩沖池(8K):

    ??create?bufferpool?ibmdefault8k?IMMEDIATE??SIZE?5000?PAGESIZE?8?K?;
    創建緩沖池(16K)(OA_DIVERTASKRECORD):
    ??create?bufferpool?ibmdefault16k?IMMEDIATE??SIZE?5000?PAGESIZE?16?K?;
    創建緩沖池(32K)(OA_TASK):
    ??create?bufferpool?ibmdefault32k?IMMEDIATE??SIZE?5000?PAGESIZE?32?K?;

    創建表空間:

    ??CREATE?TABLESPACE?exoatbs?IN?DATABASE?PARTITION?GROUP?IBMDEFAULTGROUP?PAGESIZE?8K?MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoacontainer')?EXTENTSIZE?32?PREFETCHSIZE?16??BUFFERPOOL?IBMDEFAULT8K??OVERHEAD?24.10?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    ??CREATE?TABLESPACE?exoatbs16k??IN?DATABASE?PARTITION?GROUP?IBMDEFAULTGROUP?PAGESIZE?16K?MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoacontainer16k'???)?EXTENTSIZE?32??PREFETCHSIZE?16??BUFFERPOOL?IBMDEFAULT16K??OVERHEAD?24.1?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    ??CREATE?TABLESPACE?exoatbs32k??IN?DATABASE?PARTITION?GROUP?IBMDEFAULTGROUP?PAGESIZE?32K?MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoacontainer32k'???)?EXTENTSIZE?32??PREFETCHSIZE?16??BUFFERPOOL?IBMDEFAULT32K??OVERHEAD?24.1?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    GRANT?USE?OF?TABLESPACE?exoatbs?TO?PUBLIC;
    GRANT?USE?OF?TABLESPACE?exoatbs16k?TO?PUBLIC;
    GRANT?USE?OF?TABLESPACE?exoatbs32k?TO?PUBLIC;

    創建系統表空間:

    ??CREATE?TEMPORARY?TABLESPACE?exoasystmp?IN?DATABASE?PARTITION?GROUP?IBMTEMPGROUP?PAGESIZE?8K??MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoasystmp'???)?EXTENTSIZE?32?PREFETCHSIZE?16?BUFFERPOOL?IBMDEFAULT8K??OVERHEAD?24.10?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    ??CREATE?TEMPORARY?TABLESPACE?exoasystmp16k?IN?DATABASE?PARTITION?GROUP?IBMTEMPGROUP?PAGESIZE?16K?MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoasystmp16k'??)?EXTENTSIZE?32?PREFETCHSIZE?16?BUFFERPOOL?IBMDEFAULT16K?OVERHEAD?24.10?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    ??CREATE?TEMPORARY?TABLESPACE?exoasystmp32k?IN?DATABASE?PARTITION?GROUP?IBMTEMPGROUP?PAGESIZE?32K?MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoasystmp32k')?EXTENTSIZE?32?PREFETCHSIZE?16?BUFFERPOOL?IBMDEFAULT32K?OVERHEAD?24.10?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    1.?啟動實例(db2inst1):

    db2start

    2.?停止實例(db2inst1):

    db2stop

    3.?列出所有實例(db2inst1)

    db2ilist

    5.列出當前實例:

    db2?get?instance

    4.?察看示例配置文件:

    db2?get?dbm?cfg|more

    5.?更新數據庫管理器參數信息:

    db2?update?dbm?cfg?using?para_name?para_value

    6.?創建數據庫:

    db2?create?db?test

    7.?察看數據庫配置參數信息

    db2?get?db?cfg?for?test|more

    8.?更新數據庫參數配置信息

    db2?update?db?cfg?for?test?using?para_name?para_value

    10.刪除數據庫:

    db2?drop?db?test

    11.連接數據庫

    db2?connect?to?test

    12.列出所有表空間的詳細信息。

    db2?list?tablespaces?show?detail

    13.查詢數據:

    db2?select?*?from?tb1

    14.刪除數據:

    db2?delete?from?tb1?where?id=1

    15.創建索引:

    db2?create?index?idx1?on?tb1(id);

    16.創建視圖:

    db2?create?view?view1?as?select?id?from?tb1

    17.查詢視圖:

    db2?select?*?from?view1

    18.節點編目

    db2?catalog?tcp?node?node_name?remote?server_ip?server?server_port

    19.察看端口號

    db2?get?dbm?cfg|grep?SVCENAME

    20.測試節點的附接

    db2?attach?to?node_name

    21.察看本地節點

    db2?list?node?direcotry

    22.節點反編目

    db2?uncatalog?node?node_name

    23.數據庫編目

    db2?catalog?db?db_name?as?db_alias?at?node?node_name

    24.察看數據庫的編目

    db2?list?db?directory

    25.連接數據庫

    db2?connect?to?db_alias?user?user_name?using?user_password

    26.數據庫反編目

    db2?uncatalog?db?db_alias

    27.導出數據

    db2?export?to?myfile?of?ixf?messages?msg?select?*?from?tb1

    28.導入數據

    db2?import?from?myfile?of?ixf?messages?msg?replace?into?tb1

    29.導出數據庫的所有表數據

    db2move?test?export

    30.生成數據庫的定義

    db2look?-d?db_alias?-a?-e?-m?-l?-x?-f?-o?db2look.sql

    31.創建數據庫

    db2?create?db?test1

    32.生成定義

    db2?-tvf?db2look.sql

    33.導入數據庫所有的數據

    db2move?db_alias?import

    34.重組檢查

    db2?reorgchk

    35.重組表tb1

    db2?reorg?table?tb1

    36.更新統計信息

    db2?runstats?on?table?tb1

    37.備份數據庫test

    db2?backup?db?test

    38.恢復數據庫test

    db2?restore?db?test

    399\.列出容器的信息

    db2?list?tablespace?containers?for?tbs_id?show?detail

    40.創建表:

    db2?ceate?table?tb1(id?integer?not?null,name?char(10))

    41.列出所有表

    db2?list?tables

    42.插入數據:

    db2?insert?into?tb1?values(1,’sam’);

    db2?insert?into?tb2?values(2,’smitty’);

    .?建立數據庫DB2_GCB?

    CREATE?DATABASE?DB2_GCB?ON?G:?ALIAS?DB2_GCB?

    USING?CODESET?GBK?TERRITORY?CN?COLLATE?USING?SYSTEM?DFT_EXTENT_SZ?32?

    2.?連接數據庫?

    connect?to?sample1?user?db2admin?using?8301206?

    3.?建立別名?

    create?alias?db2admin.tables?for?sysstat.tables;?

    CREATE?ALIAS?DB2ADMIN.VIEWS?FOR?SYSCAT.VIEWS?

    create?alias?db2admin.columns?for?syscat.columns;?

    create?alias?guest.columns?for?syscat.columns;?

    4.?建立表?

    create?table?zjt_tables?as?

    (select?*?from?tables)?definition?only;?

    create?table?zjt_views?as?

    (select?*?from?views)?definition?only;?

    5.?插入記錄?

    insert?into?zjt_tables?select?*?from?tables;?

    insert?into?zjt_views?select?*?from?views;?

    6.?建立視圖?

    create?view?V_zjt_tables?as?select?tabschema,tabname?from?zjt_tables;?

    7.?建立觸發器?

    CREATE?TRIGGER?zjt_tables_del?

    AFTER?DELETE?ON?zjt_tables?

    REFERENCING?OLD?AS?O?

    FOR?EACH?ROW?MODE?DB2SQL?

    Insert?into?zjt_tables1?values(substr(o.tabschema,1,8),substr(o.tabname,1,10))?

    8.?建立唯一性索引?

    CREATE?UNIQUE?INDEX?I_ztables_tabname?

    [size=3]ON?zjt_tables(tabname);?

    9.?查看表?

    select?tabname?from?tables?

    where?tabname='ZJT_TABLES';?

    10.?查看列?

    select?SUBSTR(COLNAME,1,20)?as?列名,TYPENAME?as?類型,LENGTH?as?長度?

    from?columns?

    where?tabname='ZJT_TABLES';?

    11.?查看表結構?

    db2?describe?table?user1.department?

    db2?describe?select?*?from?user.tables?

    12.?查看表的索引?

    db2?describe?indexes?for?table?user1.department?

    13.?查看視圖?

    select?viewname?from?views?

    where?viewname='V_ZJT_TABLES';?

    14.?查看索引?

    select?indname?from?indexes?

    where?indname='I_ZTABLES_TABNAME';?

    15.?查看存貯過程?

    SELECT?SUBSTR(PROCSCHEMA,1,15),SUBSTR(PROCNAME,1,15)?

    FROM?SYSCAT.PROCEDURES;?

    16.?類型轉換(cast)?

    ip?datatype:varchar?

    select?cast(ip?as?integer)+50?from?log_comm_failed?

    17.?重新連接?

    connect?reset?

    18.?中斷數據庫連接?

    disconnect?db2_gcb?

    19.?view?application?

    LIST?APPLICATION;?

    20.?kill?application?

    FORCE?APPLICATION(0);?

    db2?force?applications?all?(強迫所有應用程序從數據庫斷開)?

    21.?lock?table

    lock?table?test?in?exclusive?mode?

    22.?共享?

    lock?table?test?in?share?mode?

    23.?顯示當前用戶所有表?

    list?tables?

    24.?列出所有的系統表?

    list?tables?for?system?

    25.?顯示當前活動數據庫?

    list?active?databases?

    26.?查看命令選項?

    list?command?options?

    27.?系統數據庫目錄?

    LIST?DATABASE?DIRECTORY?

    28.?表空間?

    list?tablespaces?

    29.?表空間容器?

    LIST?TABLESPACE?CONTAINERS?FOR?

    Example:?LIST?TABLESPACE?CONTAINERS?FOR?1?

    30.?顯示用戶數據庫的存取權限?

    GET?AUTHORIZATIONS?

    31.?啟動實例?

    DB2START?

    32.?停止實例?

    db2stop?

    33.?表或視圖特權?

    grant?select,delete,insert,update?on?tables?to?user?

    grant?all?on?tables?to?user?WITH?GRANT?OPTION?

    34.?程序包特權?

    GRANT?EXECUTE?

    ON?PACKAGE?PACKAGE-name?

    TO?PUBLIC?

    35.?模式特權?

    GRANT?CREATEIN?ON?SCHEMA?SCHEMA-name?TO?USER?

    36.?數據庫特權?

    grant?connect,createtab,dbadm?on?database?to?user?

    37.?索引特權?

    grant?control?on?index?index-name?to?user?

    38.?信息幫助?(??XXXnnnnn?)?

    例:??SQL30081?

    39.?SQL?幫助(說明?SQL?語句的語法)?

    help?statement?

    例如,help?SELECT?

    40.?SQLSTATE?幫助(說明?SQL?的狀態和類別代碼)?

    ??sqlstate?或???class-code?

    41.?更改與"管理服務器"相關的口令?

    db2admin?setid?username?password?

    42.?創建?SAMPLE?數據庫?

    db2sampl?

    db2sampl?F:(指定安裝盤)?

    43.?使用操作系統命令?

    !?dir?

    44.?轉換數據類型?(cast)?

    SELECT?EMPNO,?CAST(RESUME?AS?VARCHAR(370))?

    FROM?EMP_RESUME?

    WHERE?RESUME_FORMAT?=?'ascii'?

    45.?UDF

    要運行?DB2?Java?存儲過程或?UDF,還需要更新服務器上的?DB2?數據庫管理程序配置,以包括在該機器上安裝?JDK?的路徑?

    db2?update?dbm?cfg?using?JDK11_PATH?d:sqllibjavajdk?

    TERMINATE?

    update?dbm?cfg?using?SPM_NAME?sample?

    46.?檢查?DB2?數據庫管理程序配置?

    db2?get?dbm?cfg?

    47.?檢索具有特權的所有授權名?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'DATABASE'?FROM?SYSCAT.DBAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'TABLE?'?FROM?SYSCAT.TABAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'PACKAGE?'?FROM?SYSCAT.PACKAGEAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'INDEX?'?FROM?SYSCAT.INDEXAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'COLUMN?'?FROM?SYSCAT.COLAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'SCHEMA?'?FROM?SYSCAT.SCHEMAAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'SERVER?'?FROM?SYSCAT.PASSTHRUAUTH?

    ORDER?BY?GRANTEE,?GRANTEETYPE,?3?

    create?table?yhdab?

    (id?varchar(10),?

    password?varchar(10),?

    ywlx?varchar(10),?

    kh?varchar(10));?

    create?table?ywlbb?

    (ywlbbh?varchar(8),?

    ywmc?varchar(60))?

    48.?修改表結構?

    alter?table?yhdab?ALTER?kh?SET?DATA?TYPE?varchar(13);?

    alter?table?yhdab?ALTER?ID?SET?DATA?TYPE?varchar(13);?

    alter?table?lst_bsi?alter?bsi_money?set?data?type?int;?

    insert?into?yhdab?values?

    ('20000300001','123456','user01','20000300001'),?

    ('20000300002','123456','user02','20000300002');?

    49.?業務類型說明?

    insert?into?ywlbb?values?

    ('user01','業務申請'),?

    ('user02','業務撤消'),?

    ('user03','費用查詢'),?

    ('user04','費用自繳'),?

    ('user05','費用預存'),?

    ('user06','密碼修改'),?

    ('user07','發票打印'),?

    ('gl01','改用戶基本信息'),?

    ('gl02','更改支付信息'),?

    ('gl03','日統計功能'),?

    ('gl04','沖帳功能'),?

    ('gl05','對帳功能'),?

    ('gl06','計費功能'),?

    ('gl07','綜合統計')?

    備份數據庫:
    CONNECT?TO?EXOA;
    QUIESCE?DATABASE?IMMEDIATE?FORCE?CONNECTIONS;
    CONNECT?RESET;
    BACKUP?DATABASE?EXOA?TO?"/home/exoa2/db2bak/"?WITH?2?BUFFERS?BUFFER?1024?PARALLELISM?1?WITHOUT?PROMPTING;
    CONNECT?TO?EXOA;
    UNQUIESCE?DATABASE;
    CONNECT?RESET;

    以下是小弟在使用db2move中的一些經驗,希望對大家有所幫助。?

    ?db2???connect???to??YOURDB???
    連接數據庫?

    ?db2look?-d??YOURDB??-a?-e?-x?-o?creatab.sql?
    導出建庫表的SQL?

    ?db2move???YOURDB??export?
    用db2move將數據備份出來?

    ?vi???creatab.sql?
    如要導入的數據庫名與原數據庫不同,要修改creatab.sql中CONNECT?項?
    如相同則不用更改?

    ?db2move??NEWDB??load?
    將數據導入新庫中?

    在導入中可能因為種種原因發生中斷,會使數據庫暫掛?
    db2????list?tablespaces???show???detail?
    如:?
    ??????詳細說明:?
    ?????裝入暫掛?
    ?總頁數??????????????????????????=?1652?
    ?可用頁數????????????????????????=?1652?
    ?已用頁數?????????????????????????=?1652?
    ?空閑頁數?????????????????????????=?不適用?
    ?高水位標記(頁)?????????????????=?不適用?
    ?頁大小(字節)???????????????????=?4096?
    ?盤區大小(頁)???????????????????=?32?
    ?預讀取大小(頁)?????????????????=?32?
    ?容器數???????????????????????????=?1?
    ?狀態更改表空間標識????????????????????=?2?
    ?狀態更改對象標識??????????????????????=?59?

    ?db2?select?tabname,tableid?from?syscat.tables?where?tableid=59?
    查看是哪張表掛起?

    表名知道后到db2move.lst(在db2move??YOURDB??export的目錄中)中找到相應的.ixf文件?
    ?db2?load?from?tab11.ixf?of?ixf?terminate?into?db2admin.xxxxxxxxx?
    tab11.ixf對應的是xxxxxxxxx表?

    數據庫會恢復正常,可再用db2?list?tablespaces?show?detail查看

    30.不能通過GRANT授權的權限有哪種?

    SYSAM

    SYSCTRL

    SYSMAINT

    要更該述權限必須修改數據庫管理器配置參數

    31.表的類型有哪些?

    永久表(基表)

    臨時表(說明表)

    臨時表(派生表)

    32.如何知道一個用戶有多少表?

    SELECT*FROMSYSIBM.SYSTABLESWHERECREATOR='USER'

    33.如何知道用戶下的函數?

    select*fromIWH.USERFUNCTION

    select*fromsysibm.SYSFUNCTIONS

    34.如何知道用戶下的VIEW數?

    select*fromsysibm.sysviewsWHERECREATOR='USER'

    35.如何知道當前DB2的版本?

    select*fromsysibm.sysvERSIONS

    36.如何知道用戶下的TRIGGER數?

    select*fromsysibm.SYSTRIGGERSWHERESCHEMA='USER'

    37.如何知道TABLESPACE的狀況?

    select*fromsysibm.SYSTABLESPACES

    38.如何知道SEQUENCE的狀況?

    select*fromsysibm.SYSSEQUENCES

    39.如何知道SCHEMA的狀況?

    select*fromsysibm.SYSSCHEMATA

    40.如何知道INDEX的狀況?

    select*fromsysibm.SYSINDEXES

    41.如何知道表的字段的狀況?

    select*fromsysibm.SYSCOLUMNSWHERETBNAME='AAAA'

    42.如何知道DB2的數據類型?

    select*fromsysibm.SYSDATATYPES

    43.如何知道BUFFERPOOLS狀況?

    select*fromsysibm.SYSBUFFERPOOLS

    44.DB2表的字段的修改限制?

    只能修改VARCHAR2類型的并且只能增加不能減少.

    45.如何查看表的結構?

    DESCRIBLETABLETABLE_NAME

    OR

    DESCRIBLESELECT*FROMSCHEMA.TABLE_NAME

    ?
    ?

    ? ? ?
    ?
    posted @ 2006-12-28 16:57 MyJavaWorld 閱讀(2763) | 評論 (0)編輯 收藏
    主站蜘蛛池模板: 免费国产成人高清在线观看麻豆 | 亚洲国产天堂久久久久久| 亚洲18在线天美| 免费精品国产自产拍在线观看图片| 亚洲AV日韩精品久久久久久| 久久久WWW免费人成精品| 亚洲中文字幕久久精品无码喷水| 国产午夜精品理论片免费观看| 亚洲熟妇中文字幕五十中出| 91视频免费观看高清观看完整| 国产精品亚洲片在线观看不卡 | 亚洲色偷偷综合亚洲av78| 成人免费在线视频| 国产偷国产偷亚洲高清在线| 全部免费毛片在线| 免费播放在线日本感人片| 亚洲av成人无码久久精品| 在线永久看片免费的视频| 亚洲国产美女精品久久久| 亚洲精品第一国产综合境外资源| 水蜜桃视频在线观看免费播放高清| 久久精品亚洲综合专区| 免费福利网站在线观看| 亚洲av午夜电影在线观看| 亚洲中文字幕无码专区| 99久9在线|免费| 亚洲人成色777777老人头| 国产综合亚洲专区在线| 18禁美女裸体免费网站| 国产偷国产偷亚洲清高APP| 区久久AAA片69亚洲| 亚洲黄色免费电影| 美女黄色免费网站| 亚洲高清在线视频| 免费无码黄动漫在线观看| 一个人免费观看视频在线中文| 亚洲日韩区在线电影| 国产一级淫片免费播放| 午夜视频在线免费观看| 国产成人亚洲综合在线| 色婷婷亚洲十月十月色天|