自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

DBase:DB2必須了解的常用命令及技巧

數(shù)據(jù)庫 數(shù)據(jù)庫運維
這里將為大家講一講幾個DBase:DB2常用命令及技巧,希望通過這些命令和技巧,能簡化大家的工作,提高工作效率。

1.db2里面的字符串連接可用"||"這個進行連接

2.如何快速刪除大批量的數(shù)據(jù)表(test為數(shù)據(jù)庫表)

最常用也是最多人用的語句:delete from test,但這種做法,效率比較低,花費時間太長,因為在刪除數(shù)據(jù)時,要記數(shù)據(jù)庫日志。

import from /dev/null of del replace into test//先清空,再導入數(shù)據(jù)(由于導入的文件為空,故相當于清空表數(shù)據(jù)),這種刪除的速度較快

ALTER TABLE test activate NOT LOGGED initially WITH EMPTY TABLE ;刪除表中的數(shù)據(jù),不記日志,這種處理最快

3.導入、導出數(shù)據(jù),支持的文件有ixf,del文件

db2 "export to fileName.del of del select * from tableName" //db2中把表中的數(shù)據(jù)導入到文件

db2 "import from fileName.del of del insert into tableName " //db2中把文件中的數(shù)據(jù)導入到表

4.DB2中檢查表是否已存在

select * from "SYSIBM"."SYSTABLES" where lower(name) ='afa_maintransdtl'

5.處理db2鎖表問題:

db2 “connect to afa”

db2 “get snapshot for locks on 實例名”

db2 “terminate”

然后查看相關(guān)信息,找到被鎖定的表,執(zhí)行以下語句:

db2 “force application(application handle) 注:application handle對應的是一個整數(shù)

6.在服務器上創(chuàng)建存儲過程時:

應為存儲過程指定特定的換行符,然后執(zhí)行下面的語句:

db2 -td@ -vf fileName.sql (其中@為存儲過程中指定的換行符)

7. 查看索引是否起作用

runstats on table afa.yj_jywtk with distribution and detailed indexes all;

8.截取數(shù)據(jù)庫快照:

db2 "connect to 實例名"

db2 "update monitor switches using lock ON sort ON bufferpool ON uow ON table ON statement ON"

db2 "get snapshot for all on 實例名"

9. 查看存儲過程

select procname,text from sysibm.sysprocedures;

10.list tables 查看數(shù)據(jù)庫表

11.查找字符在字串中的位置

locate('y','xyz')

查找'y'在'xyz'中的位置。

12. 計算兩個日期的相差天數(shù)

days(date('2007-03-01'))-days(date('2007-02-28'))

days 返回的是從 0001-01-01 開始計算的天數(shù)

13. 為一個用戶訪問另一個實例創(chuàng)建表映射

create alias tableName for 實例名. tableName

14.如何查看表結(jié)構(gòu)

describe table tableName

or

describe select * from table_name

15.如何重新啟動數(shù)據(jù)庫?

restart database database_name

16.如何激活數(shù)據(jù)庫?

activate database database_name

17.如何停止數(shù)據(jù)庫?

deactivate database database_name

18.如何重命名表?

rename table_old to table_new

19.如何定義序列?

create sequence orderseq start with 1 increment by 1 no maxvalue no cycle cache24

20.如何查看一個表的索引

describe indexes for table tableName show detail

【編輯推薦】

  1. 利用DB2 pureXML管理XML數(shù)據(jù)實踐
  2. 如何在DB2中提高IMPORT性能
  3. 使用DB2必須了解的幾個知識點
責任編輯:彭凡 來源: DIY部落
相關(guān)推薦

2011-03-11 17:52:33

DB2命令

2010-08-26 11:37:38

DB2命令

2010-09-30 10:13:35

DB2常用命令

2010-08-06 08:43:02

DB2常用命令

2010-08-20 12:21:31

DB2常用命令

2010-08-19 15:23:14

DB2常用命令

2010-03-19 10:08:01

linux 常用命令

2010-11-04 11:07:56

DB2管理命令

2011-03-15 09:59:57

2009-04-01 11:39:39

視圖DB2

2011-03-15 09:02:01

IPtables常用命令

2014-07-25 10:55:36

Linux命令

2011-03-16 10:07:00

2014-01-02 09:57:56

PostgreSQL命令

2011-01-19 17:00:09

Postfix常用命令

2022-09-06 07:56:36

ZookeeperAPI

2020-09-28 15:14:31

Linux常用命令實用命令

2010-04-07 11:21:28

Oracle常用命令

2022-05-05 08:08:55

Podman命令Linux

2015-07-23 17:09:38

Mysql啟動登錄常用命令
點贊
收藏

51CTO技術(shù)棧公眾號