Jawaban:
Peramal:
The null
literal tidak memiliki jenis, tapi
null
dapat dilemparkan ke jenis apa pun, dan ini mungkin perlu saat
mengendalikan jenis pengembalian decode
fungsi, misalnya:
select decode('A','B',to_char(null),'A','1') from dual;
DECODE('A','B',TO_CHAR(NULL),'A','1')
-------------------------------------
1
select decode('A','B',to_number(null),'A','1') from dual;
DECODE('A','B',TO_NUMBER(NULL),'A','1')
---------------------------------------
1
union
ketika blok permintaan pertama menyertakan anull
null
nilai yang disimpan dalam database selalu memiliki tipe:
create table t(n integer, s varchar(10));
insert into t values(null, null);
select decode('A','B',n,'A','1') from t;
DECODE('A','B',N,'A','1')
-------------------------
1
select decode('A','B',s,'A','1') from t;
DECODE('A','B',S,'A','1')
-------------------------
1
SQL Server, int
SELECT NULL AS foo INTO dbo.bar
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'bar'
DROP TABLE dbo.bar
MySQL, binary (0)
CREATE TABLE mydb.foo (select NULL AS bar);
EXPLAIN mydb.foo;
DROP TABLE mydb.foo;
select isnumeric(null)
= 0 ... menarik
Oracle dalam beberapa hal beberapa tipe string .
Itulah yang dikatakan Pembaca ADO kepada saya. di sini adalah Script Powershell:
[System.Reflection.Assembly]::LoadWithPartialName("System.Data.OracleClient")
$ConnectionString = "Data Source=myTNS;User ID=myUSER;Password=myPassword"
$conn=new-object System.Data.OracleClient.OracleConnection
$conn.ConnectionString=$ConnectionString
$conn.Open()
$sql = "Select NULL xx from DUAL"
$cmd=new-object System.Data.OracleClient.OracleCommand($sql,$conn)
$r = $cmd.ExecuteReader()
$r.GetSchemaTable() | % { $_
}
Itu memberi
ColumnName : XX
ColumnOrdinal : 0
ColumnSize : 0
NumericPrecision : 0
NumericScale : 0
DataType : System.String
ProviderType : 22
IsLong : False
AllowDBNull : True
IsAliased :
IsExpression :
IsKey :
IsUnique :
BaseSchemaName :
BaseTableName :
BaseColumnName :
ProviderSpecificDataType : System.Data.OracleClient.OracleString
Perhatikan barisnya
PenyediaSpecificDataType: System.Data.OracleClient.OracleString
postgres:
create table foo as select null as bar;
WARNING: column "bar" has type "unknown"
DETAIL: Proceeding with relation creation anyway.
postgres=> \d foo
Column | Type | Modifiers
--------+---------+-----------
bar | unknown |