經(jīng)常在前輩們的SQL中可以看到CAST的用法,例如:

WITH T AS,

A AS),1 FROM T

UNION ALL

SELECT A||L,V+1 FROM A, T WHERE INSTR=0 AND V<5

)

SELECT * FROM A;

例如上面的with遞歸語句,但是CAST因為用的比較少,今天就先給自己掃個盲了,引用Oracle的官方文檔中對于CAST的描述如下:

CAST

CAST converts values from one data type to another.

Return Value

The data type specified by type_name.

Syntax

CAST

Arguments

expr can be an expression in one of the data types.

type_name is one of the data types listed in Table1-2,"Dimensional Data Types".

Table 3-1 shows which data types can be cast into which other built-in data types. NUMBER includes NUMBER, DECIMAL, and INTEGER. DATETIME includes DATE,TIMESTAMP, TIMESTAMP WITH TIMEZONE, and TIMESTAMP WITH LOCAL TIMEZONE. INTERVAL includes INTERVAL DAY TO SECOND and INTERVAL YEAR TO MONTH.

Table 3-1 Compatible Data Types

FromTo BINARY_FLOAT, BINARY_DOUBLETo CHAR, VARCHAR2To NUMBERTo DATETIME, INTERVALTo NCHAR, NVARCHAR2

BINARY_FLOAT, BINARY_DOUBLE

yes

yes

yes

no

yes

1.《unioncast Oracle的Cast的用法 -電腦資料》援引自互聯(lián)網(wǎng),旨在傳遞更多網(wǎng)絡(luò)信息知識,僅代表作者本人觀點,與本網(wǎng)站無關(guān),侵刪請聯(lián)系頁腳下方聯(lián)系方式。

2.《unioncast Oracle的Cast的用法 -電腦資料》僅供讀者參考,本網(wǎng)站未對該內(nèi)容進行證實,對其原創(chuàng)性、真實性、完整性、及時性不作任何保證。

3.文章轉(zhuǎn)載時請保留本站內(nèi)容來源地址,http://f99ss.com/jiaoyu/166573.html