首页 > Perl, Programming > PostgreSQL与标准SQL数据类型对应表

PostgreSQL与标准SQL数据类型对应表

2008年9月28日 Galaxy 发表评论 阅读评论

__DATA__
## Format: for each type, there are 6 items, space separated:
## 1. The given name, from the Postgres source code (pg_type.h)
## 2. The function name we use to do the quoting, or 0 if we do not bind it
## 3. The function name we use for DE-quoting
## 4. The closest SQL_ datatype, or 0 if there is none. May be multiple, separated by |
## 5. Whether this is the one to use for reverse SQL_ type mapping
## 6. What type of SV we can put this in: 1: IV 2: NV

## Simple quoting (e.g. text) – wrap in single quotes, escape backslashes and apostrophes
## This is also the default action for types not specified here
varchar quote_string dequote_string SQL_VARCHAR 1 0
text quote_string dequote_string SQL_LONGVARCHAR 1 0
char quote_string dequote_char SQL_CHAR 0 0
bpchar quote_string dequote_char SQL_CHAR 1 0
cid quote_string dequote_string 0 0 0

## Things that get no quoting at all (e.g. numbers)
int2 null_quote null_dequote SQL_SMALLINT|SQL_TINYINT 1 1
int4 null_quote null_dequote SQL_INTEGER 1 1
int8 null_quote null_dequote SQL_BIGINT 1 0
float4 null_quote null_dequote 0 1 2
float8 null_quote null_dequote SQL_FLOAT|SQL_DOUBLE|SQL_NUMERIC|SQL_REAL 1 2
numeric null_quote null_dequote SQL_DECIMAL 1 2
oid null_quote null_dequote 0 0 1
name null_quote null_dequote SQL_VARCHAR 0 0 ## XXX Wrong

## Boolean
bool quote_bool dequote_bool SQL_BOOLEAN 1 0

## Geometric types
point quote_geom dequote_string 0 0 0
line quote_geom dequote_string 0 0 0
lseg quote_geom dequote_string 0 0 0
box quote_geom dequote_string 0 0 0
path quote_path dequote_string 0 0 0
polygon quote_geom dequote_string 0 0 0
circle quote_circle dequote_string 0 0 0

## Similar enough to geometric types that we use the same quoting rules
tid quote_geom dequote_string 0 0 0

## Binary – very different quoting rules
bytea quote_bytea dequote_bytea SQL_VARBINARY 1 0

## Time and date
date quote_string dequote_string SQL_TYPE_DATE 1 0
time quote_string dequote_string SQL_TYPE_TIME 1 0
timestamp quote_string dequote_string SQL_TIMESTAMP|SQL_TYPE_TIMESTAMP 1 0
timestamptz quote_string dequote_string SQL_TYPE_TIMESTAMP_WITH_TIMEZONE|SQL_TYPE_TIME_WITH_TIMEZONE 1 0

__END__

Tags: ,

Related posts

分类: Perl, Programming 标签: , 170 views
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.

Locations of visitors to this page