ホームページ  >  記事  >  データベース  >  (转)C# 数据类型映射 (SQLite,MySQL,MSSQL,Oracle)

(转)C# 数据类型映射 (SQLite,MySQL,MSSQL,Oracle)

WBOY
WBOYオリジナル
2016-06-07 17:37:381829ブラウズ

一、C# vs SQLite: C#SQLite 字段名类型库类型GetFieldType(#)转换备注 F_BOOLboolBIT NOT NULLBoolean F_BOOL_NULLbool?BITBoolean F_SBYTEsbyteINT8 NOT NULLSBytesbyte_ F_SBYTE_NULLsbyte?INT8SBytesbyte_ F_BYTEbyteUINT8 NOT NULLByte F_BYTE_NULLbyte

一、C# vs SQLite:

C# SQLite

字段名 类型 库类型 GetFieldType(#) 转换 备注

F_BOOL bool BIT NOT NULL Boolean    

F_BOOL_NULL bool? BIT Boolean    

F_SBYTE sbyte INT8 NOT NULL SByte sbyte_  

F_SBYTE_NULL sbyte? INT8 SByte sbyte_  

F_BYTE byte UINT8 NOT NULL Byte    

F_BYTE_NULL byte? UINT8 Byte    

F_SHORT short INT16 NOT NULL Int16    

F_SHORT_NULL short? INT16 Int16    

F_USHORT ushort UINT16 NOT NULL UInt16 ushort_  

F_USHORT_NULL ushort? UINT16 UInt16 ushort_  

F_INT int INT32 NOT NULL Int32    

F_INT_NULL int? INT32 Int32    

F_UINT uint UINT32 NOT NULL UInt32 uint_  

F_UINT_NULL uint? UINT32 UInt32 uint_  

F_LONG long INT64 NOT NULL Int64    

F_LONG_NULL long? INT64 Int64    

F_ULONG ulong UINT64 NOT NULL UInt64 ulong_  

F_ULONG_NULL ulong? UINT64 UInt64 ulong_  

F_FLOAT float FLOAT NOT NULL Double   不转兼容

F_FLOAT_NULL float? FLOAT Double   不转兼容

F_DOUBLE double DOUBLE NOT NULL Double    

F_DOUBLE_NULL double? DOUBLE Double    

F_DECIMAL decimal DECIMAL NOT NULL Decimal   存取不一:: [-79228162514264300000000000000] != [-79228162514264337593543950335]

F_DECIMAL_NULL decimal? DECIMAL Decimal   存取不一:: [-79228162514264300000000000000] != [-79228162514264337593543950335]

F_CHAR char TEXT NOT NULL String    

F_CHAR_NULL char? TEXT String    

F_STRING string TEXT NOT NULL String    

F_STRING_NULL string TEXT String    

F_DATETIME DateTime TEXT NOT NULL String    

F_DATETIME_NULL DateTime? TEXT String    

           

二、 C# vs MySQL:

C# MySQL

字段名 类型 库类型 GetFieldType(#) 转换 备注

F_BOOL bool BOOL NOT NULL Boolean    

F_BOOL_NULL bool? BOOL NULL Boolean    

F_SBYTE sbyte TINYINT NOT NULL SByte sbyte_  

F_SBYTE_NULL sbyte? TINYINT NULL SByte sbyte_  

F_BYTE byte TINYINT UNSIGNED NOT NULL Byte    

F_BYTE_NULL byte? TINYINT UNSIGNED NULL Byte    

F_SHORT short SMALLINT NOT NULL Int16    

F_SHORT_NULL short? SMALLINT NULL Int16    

F_USHORT ushort SMALLINT UNSIGNED NOT NULL UInt16 ushort_  

F_USHORT_NULL ushort? SMALLINT UNSIGNED NULL UInt16 ushort_  

F_INT int INT NOT NULL Int32    

F_INT_NULL int? INT NULL Int32    

F_UINT uint INT UNSIGNED NOT NULL UInt32 uint_  

F_UINT_NULL uint? INT UNSIGNED NULL UInt32 uint_  

F_LONG long BIGINT NOT NULL Int64    

F_LONG_NULL long? BIGINT NULL Int64    

F_ULONG ulong BIGINT UNSIGNED NOT NULL UInt64 ulong_  

F_ULONG_NULL ulong? BIGINT UNSIGNED NULL UInt64 ulong_  

F_FLOAT float FLOAT NOT NULL Single   极值溢出

F_FLOAT_NULL float? FLOAT NULL Single   极值溢出

F_DOUBLE double DOUBLE NOT NULL Double    

F_DOUBLE_NULL double? DOUBLE NULL Double    

F_DECIMAL decimal DECIMAL NOT NULL Decimal   极值溢出

F_DECIMAL_NULL decimal? DECIMAL NULL Decimal   极值溢出

F_CHAR char CHARACTER NOT NULL String   中文报错

F_CHAR_NULL char? CHARACTER NULL String   中文报错

F_STRING string VARCHAR(50) NOT NULL String    

F_STRING_NULL string VARCHAR(50) NULL String    

F_DATETIME DateTime DATETIME NOT NULL DateTime    

F_DATETIME_NULL DateTime? DATETIME NULL DateTime    

           

三、 C# vs MSSQL:

C# MSSQL

字段名 类型 库类型 GetFieldType(#) 转换 备注

F_BOOL bool bit NOT NULL Boolean    

F_BOOL_NULL bool? bit NULL Boolean    

F_SBYTE sbyte smallint NOT NULL Int16 sbyte_short  

F_SBYTE_NULL sbyte? smallint NULL Int16 sbyte_short  

F_BYTE byte tinyint NOT NUL; Byte    

F_BYTE_NULL byte? tinyint NULL Byte    

F_SHORT short smallint NOT NULL Int16    

F_SHORT_NULL short? smallint NULL Int16    

F_USHORT ushort int NOT NULL Int32 ushort_int  

F_USHORT_NULL ushort? int NULL Int32 ushort_int  

F_INT int int NOT NULL Int32    

F_INT_NULL int? int NULL Int32    

F_UINT uint bigint NOT NULL Int64 uint_long  

F_UINT_NULL uint? bigint NULL Int64 uint_long  

F_LONG long bigint NOT NULL Int64    

F_LONG_NULL long? bigint NULL Int64    

F_ULONG ulong real NOT NULL Single ulong_float  

F_ULONG_NULL ulong? real NULL Single ulong_float  

F_FLOAT float real NOT NULL Single    

F_FLOAT_NULL float? real NULL Single    

F_DOUBLE double float NOT NULL Double    

F_DOUBLE_NULL double? float NULL Double    

F_DECIMAL decimal decimal NOT NULL Decimal   极值溢出

F_DECIMAL_NULL decimal? decimal NULL Decimal   极值溢出

F_CHAR char char(1) NOT NULL String    

F_CHAR_NULL char? char(1) NULL String    

F_STRING string varchar(50) NOT NULL F_STRING:    

F_STRING_NULL string varchar(50) NULL String    

F_DATETIME DateTime datetime NOT NULL DateTime  

F_DATETIME_NULL DateTime? datetime NULL DateTime    

           

四、C# vs Oracle:

C# Oracle

字段名 类型 库类型 GetFieldType(#) 转换 备注

F_BOOL bool CHAR(1) NOT NULL String bool_string  

F_BOOL_NULL bool? CHAR(1) String bool_string  

F_SBYTE sbyte NUMBER(3) NOT NULL Int16 sbyte_short  

F_SBYTE_NULL sbyte? NUMBER(3) Int16 sbyte_short  

F_BYTE byte NUMBER(3) NOT NULL Int16 byte_short  

F_BYTE_NULL byte? NUMBER(3) Int16 byte_short  

F_SHORT short NUMBER(5) NOT NULL Int32 short_int  

F_SHORT_NULL short? NUMBER(5) Int32 short_int  

F_USHORT ushort NUMBER(5) NOT NULL Int32 ushort_int  

F_USHORT_NULL ushort? NUMBER(5) Int32 ushort_int  

F_INT int NUMBER(10) NOT NULL Int64 int_long  

F_INT_NULL int? NUMBER(10) Int64 int_long  

F_UINT uint NUMBER(10) NOT NULL Int64 uint_long  

F_UINT_NULL uint? NUMBER(10) Int64 uint_long  

F_LONG long NUMBER(19) NOT NULL Decimal long_decimal  

F_LONG_NULL long? NUMBER(19) Decimal long_decimal  

F_ULONG ulong NUMBER(19) NOT NULL Decimal ulong_decimal  

F_ULONG_NULL ulong? NUMBER(19) Decimal ulong_decimal  

F_FLOAT float BINARY_FLOAT NOT NULL Single    

F_FLOAT_NULL float? BINARY_FLOAT Single    

F_DOUBLE double BINARY_DOUBLE NOT NULL Double   极值溢出

F_DOUBLE_NULL double? BINARY_DOUBLE Double   极值溢出

F_DECIMAL decimal DECIMAL(33,3) NOT NULL Decimal    

F_DECIMAL_NULL decimal? DECIMAL(33,3) Decimal    

F_CHAR char CHAR(1) NOT NULL String    

F_CHAR_NULL char? CHAR(1) String    

F_STRING string VARCHAR(50) NOT NULL String   不允许空字符

F_STRING_NULL string VARCHAR(50) String   不允许空字符

F_DATETIME DateTime TIMESTAMP NOT NULL DateTime   大值读取报错

F_DATETIME_NULL DateTime? TIMESTAMP DateTime   大值读取报

 

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
前の記事: 数据库50道题次の記事: LevelDb系列之简介