q3256 发表于 2016-11-12 09:41:15

DB2 Special Functions

  除法

保留小数的除法. (比如保留两位小数)
例子: 如何实现类似的算式 12345/100 = 123.45

cast( ROUND( DECIMAL( 12345, 13, 2)/100, 2) as decimal(13,2) )
  判断一个Table是否存在 


SELECT COUNT(*)
INTO :isTablePresent
FROM FROM SYSCAT.TABLES
WHERE SYSCAT.TABLES.TABSCHEMA = 'MYSCHEMANAME' AND   
SYSCAT.TABLES.TABNAME= 'MYTABLENAME'
;
--If isTablePresent == 0 then the table does not exist, if isTablePresent == 1 the table exists, other values are impossible.

db2 -tvf myscript.db2   => option flags
db2 connect to sample   => SQL statement
db2 list tables for user=> DB2 command
db2 ?                     => general CLP help
db2 ? options             => current CLP options settings
db2 ? help                => help for syntax online help
db2 ? backup            => help for a specific DB2 command
db2 ? sql0117N            => help for a specific SQLCODE
db2 ? 42501               => help for a specific SQLSTATE
db2 ? 01                  => help for a specific class code
页: [1]
查看完整版本: DB2 Special Functions