DB2中case的使用

2021-09-01 18:53:40 字數 479 閱讀 5847

1、case 某個字段 when 某個值 then 賦予某個值 else 賦予另外個值 end

2、或者: case 某個字段 when 某個值 then 賦予另外個值 end

3、注意:

then 和 else 不一定要搭配使用

when 後面或者else後面甚至還可以執行sql**段。

例子:--1

select * from sy_corp_product

where

case n_corp_code when 969 then 123 else n_corp_code end = 969

;--2

select * from sy_corp_product where n_corp_code = 123;

--3select * from sy_corp_product where n_corp_code = 969;

1的資料集=2的資料集u3的資料集

DB2中sequence的使用

如何建立序列?例如 create sequence sequence name start with start number increment by value1 no max value no cycle cache maximum number of sequence values 第一行規...

關於DB2的使用(DB2資料命令)

公司所用的資料庫有金倉和db2 首先要用命令視窗直接開啟db2需要在cmd中輸入 db2cmd 1 啟動db2資料庫 db2start 2 連線資料庫 db2 connect to 資料庫名稱 3 建立資料庫 db2 create db 資料庫名稱 4 刪除資料庫 db2 drop db 資料庫名稱...

db2使用總結

tableid 413 24 檢視資料庫管理配置環境資訊 get db cfg for nm1226 show detail 25 更改locklist update db cfg for dbname using locklist 100000 26 更改maxlocks update db cf...