--oracle trunc()函式的用法
/**************日期*******************
*/select trunc(sysdate) from dual --
2015-03-23 今天的日期為2015-03-23
select trunc(sysdate, '
mm') from dual --
2015-03-01 返回當月第一天.
select trunc(sysdate,'
yy') from dual --
2015-01-01 返回當年第一天
select trunc(sysdate,'
dd') from dual --
2015-03-23 返回當前年月日
select trunc(sysdate,'
yyyy
') from dual --
2015-01-01 返回當年第一天
select trunc(sysdate,'
d') from dual --
2015-03-22(星期天)返回當前星期的第一天
select trunc(sysdate, '
hh') from dual --
2015-03-23 16:00:00
select trunc(sysdate, '
mi') from dual --
2015-03-23 16:32:00 trunc()函式沒有秒的精確
/***************數字*******************
*//*
trunc(number,num_digits)
number 需要截尾取整的數字。
num_digits 用於指定取整精度的數字。num_digits 的預設值為 0。
trunc()函式擷取時不進行四捨五入
*/select trunc(123.458) from dual --
123select trunc(123.458,0) from dual --
123select trunc(123.458,1) from dual --
123.4
select trunc(123.458,-
1) from dual --
120select trunc(123.458,-
4) from dual --
0select trunc(123.458,4) from dual --
123.458
select trunc(123) from dual --
123select trunc(123,1) from dual --
123select trunc(123,-
1) from dual --
120
SQL 函式 TRUNCATE詳解示例
truncate x,d x 表示需要處理的數字,d 表示需要擷取的位數。如果 d 為零,則返回的數字不含小數。d 也可以是負數,這樣會把整數的部分置零。示例如下 mysql select truncate 1.223,1 1.2mysql select truncate 1.999,1 1.9my...
TRUNCATE 命令用法
刪除一表結構,報錯,可能是鎖表原因.用truncate指令後done 刪除表中的所有行,而不記錄單個行刪除操作。語法truncate table name 引數name 是要截斷的表的名稱或要刪除其全部行的表的名稱。注釋truncate table 在功能上與不帶 where 子句的 delete ...
openat函式的用法示例
unix環境高階程式設計 的第三章和第四章出現了大量的以at結尾的函式,如openat fstatat等,書中只是粗略的說明了下,沒有實際的例子讓人很難懂。int openat int dirfd,const char pathname,int flags,mode t mode 我初看的時候有如下...