国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

數(shù)據(jù)庫移植注意事項

2024-07-21 02:06:41
字體:
供稿:網(wǎng)友
1.1      數(shù)據(jù)庫移植注意事項1.1.1 取前n條記錄
sql server:

    select top n * from xtable

oracle:

    select * from xtable where rownum <=n

db2:

    select * from xtable fetch first n rows only
1.1.2 取當(dāng)前日期
sql server:

    select getdate()

oracle:

    select sysdate from dual

db2:

    select current timestamp from sysibm.sysdummy1
1.1.3 連接字符串
sql server:

    select 'hello'+'toone'

oracle:

    select 'hello'||'toone' from dual

db2:

    select 'hello'||'toone' from sysimb.sysdummy1
1.1.4 空值轉(zhuǎn)換
sql server:

    select userid,username,isnull(email,'0') from auth_user

oracle:

    select userid,username,nvl(email,'0') from auth_user

db2:

    select userid,username,value(email,'0') from auth_user
1.1.5 類型轉(zhuǎn)換
sql server:

    select convert(varchar,getdate(),20)

oracle:

    select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual

db2:

    select varchar(current timestamp) from sysibm.sysdummy1

注1:

    ■sql server中轉(zhuǎn)換日期格式改變style參數(shù):20 ;

    ■oracle中轉(zhuǎn)換日期格式改變格式化參數(shù):yyyy-mm-dd hh24:mi:ss

        ‘yyyy’、’mm’、’dd’、’hh12’、’hh24’、’mi’、’ss’等;

    ■db2中轉(zhuǎn)換日期格式改變系統(tǒng)常量:current timestamp

        ‘current date’、’current time’等;

注2:

    ■sql server數(shù)據(jù)類型改變“數(shù)據(jù)類型參數(shù)”:int、varchar等;

    ■oracle數(shù)據(jù)類型改變函數(shù):to_char()、to_date()、to_number()等;

    ■db2數(shù)據(jù)類型改變函數(shù):varchar()、int()、date()、time()等;
1.1.6 取值判斷
sql server:

select caseconvert =

     case when g.master_type ='system'   then '管理員'

          when g.master_type ='roletype' then '特殊角色'

          else '普通用戶'

     end

from global_code g

oracle:

select  case g.master_type

          when 'system'   then '管理員'

          when 'roletype' then '特殊角色'

          else '普通用戶'

     end

     as caseconvert

from global_code g

db2:

   

select  case g.master_type

          when 'system'   then '管理員'

          when 'roletype' then '特殊角色'

          else '普通用戶'

     end

     as caseconvert

from global_code g
1.1.7 位置
sql server:

    select charindex('e','abcdef')

select patindex('%e%','abcdef')

oracle:

    select instr('abcdef','e') from dual

db2:

    select locate('e','abcdef') from sysibm.sysdummy1
1.1.8 其他函數(shù)
 

sql server

oracle

db2

長度

len()

length()

length()

取子串

substring()

substr()

substr()

 

 

 

 

 

 

 

 

 
1.2      附1.2.1 db2v8.1常用命令
■  創(chuàng)建數(shù)據(jù)庫

    在服務(wù)器上執(zhí)行

    db2 create db oatemp

■  刪除數(shù)據(jù)庫

    在服務(wù)器上執(zhí)行

    db2 drop db oatemp

■  創(chuàng)建表空間

db2 "create user temporary tablespace userspace1 managed by system using (' userspace1')"

■  啟動數(shù)據(jù)庫

    切換用戶

       su – db2inst1

    啟動數(shù)據(jù)庫:

        db2start

■  關(guān)閉數(shù)據(jù)庫

切換用戶

       su – db2inst1

    關(guān)閉數(shù)據(jù)庫

        db2stop [force]

■  創(chuàng)建遠(yuǎn)程管理節(jié)點

    進(jìn)入  db2命令窗口

    db2 catalog tcpip node asnode remote 10.1.22.176 server 50000

    db2 catalog db oadb2 as oadb2 at node asnode

■  連接數(shù)據(jù)庫

    db2 connect to oadb2 user db2inst1 using ibmdb2

■  關(guān)閉數(shù)據(jù)庫連接

    db2 terminate

■  執(zhí)行腳本

    db2 -td! -vf ioa2.db2 -z info.log

■  導(dǎo)出腳本

db2look -d oadb2 -i db2inst1 -w ibmdb2 -e -o putsql.db2 -t auth_user

db2look -d oadb2 -i db2inst1 -w ibmdb2 -e -o putsq.db2

■  查看正在使用的端口

    netstat -a

■  查詢系統(tǒng)表

    select count(*) from syscat.tables where tabschema=’db2inst1’

    select count(*) from syscat.procedures where procschema=’db2inst1’

■  常用命令

db2 "select 'drop talbe '||tabname from syscat.tables where t

abschema='db2inst1' and type='t'" >db2droptables.db2

 

db2 "select 'drop view '||tabname from syscat.tables where t

abschema='db2inst1' and type='v'" >db2dropviews.db2

 

db2 –vf db2droptables.db2 –z info.log

db2 "select username from auth_user fetch first 3 rows only"

 

■  啟動jdbc

    db2jstrt jdbc applet server 6789          (在服務(wù)器上執(zhí)行)

 
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 项城市| 湘阴县| 天峻县| 廊坊市| 克山县| 仁怀市| 邵东县| 宜州市| 汽车| 吉木萨尔县| 关岭| 彰化县| 琼中| 沙湾县| 乌兰县| 衢州市| 宜都市| 肇州县| 昌吉市| 邹平县| 黔南| 吴桥县| 翁源县| 岳西县| 西昌市| 灯塔市| 福鼎市| 德格县| 伊金霍洛旗| 安多县| 贵阳市| 昌平区| 仪征市| 沭阳县| 瓦房店市| 曲麻莱县| 门头沟区| 靖边县| 山东省| 广东省| 如皋市|