ページの先頭行へ戻る
Enterprise Postgres 12 アプリケーション開発ガイド
FUJITSU Software

4.4.2 アプリケーションのデータ型とデータベースのデータ型の関係

SQLのデータ型に対して、使用できるデータタイプは以下のとおりです。  

DbType

NpgsqlDbType

PostgreSQL
データ型

C#のデータ型

.Net Framework Typeのデータ型

Char

char

string, char[], char, IConvertible

System.String, System.Char[], System.Char

Varchar

varchar

string, char[], char, IConvertible

System.String, System.Char[], System.Char

String, StringFixedLength, AnsiString, AnsiStringFixedLength

Text

text

string, char[], char, IConvertible

System.String, System.Char[], System.Char

Binary

Bytea

bytea

byte[], ArraySegment

System.Byte[]

Int16

Smallint

int2

short, IConvertible

System.Int16

Int32

Integer

int4

int, IConvertible

System.Int32

Int64

Bigint

int8

long, IConvertible

System.Int64

Single

Real

float4

float, IConvertible

System.Single

Double

Double

float8

double, IConvertible

System.Double

Decimal, VarNumeric

Numeric

numeric

decimal, IConvertible

System.Decimal

Date

Date

date

DateTime, NpgsqlDate, IConvertible

System.DateTime

TimeTZ

timetz

DateTimeOffset, DateTime, TimeSpan

System.DateTimeOffset, System.DateTime, System.TimeSpan

Time

Time

time

TimeSpan, string

System.Timespan

DateTime, DateTime2

Timestamp

timestamp

DateTime, DateTimeOffset, NpgsqlDateTime, IConvertible

System.DateTime

DateTimeOffset

TimestampTZ

timestamptz

DateTime, DateTimeOffset, NpgsqlDateTime, IConvertible

System.DateTime

Interval

interval

TimeSpan, NpgsqlTimeSpan, string

System.TimeSpan

Boolean

bool

bool, IConvertible

System.Boolean

Bit

bit

BitArray, bool, string

System.Boolean, System.String

Uuid

uuid

Guid, string

System.Guid

Inet

inet

IPAddress, NpgsqlInet

ValueTuple<IPAddress, int>, IPAddress, NpgsqlInet

MacAddr

macaddr

PhysicalAddress

System.Net.NetworkInformation.PhysicalAddress

MacAddr8

macaddr8

PhysicalAddress

System.Net.NetworkInformation.PhysicalAddress

Box

box

NpgsqlBox

NpgsqlBox

Circle

circle

NpgsqlCircle

NpgsqlCircle

LSeg

lseg

NpgsqlLSeg

NpgsqlLSeg

Path

path

NpgsqlPath

NpgsqlPath

Point

point

NpgsqlPoint

NpgsqlPoint

Polygon

polygon

NpgsqlPolygon

NpgsqlPolygon

Array

array types

Array, IList, IList

System.Array