PostgreSQL 与 MS SQL(SQL Server) 类型映射关系

less than 1 minute read

背景

PostgreSQL与SQL Server的类型映射:

1、常用类型映射

https://www.codeproject.com/tips/1068276/convert-sql-server-database-to-postgresql

char                char / text  
nchar               char / text  
varchar             varchar / text  
nvarchar            varchar / text  
xml                 xml  
int                 integer  
bigint              bigint  
bit                 boolean  
uniqueidentifier    uuid  
hierarchyid         bytea  
geography           geography  
tinyint             smallint  
float               float  
real                real  
double              double precision  
numeric             numeric  
decimal             numeric  
money               numeric  
smallmoney          numeric  
binary              bytea  
varbinary           bytea  
image               bytea  
datetime            timestamptz  
datetime2           timestamptz  

2、所有类型映射请参考手册

2.1、SQL Server 官方类型手册

https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-2016

2.2、PostgreSQL 官方类型手册

https://www.postgresql.org/docs/devel/static/datatype.html

2.3、空间类型通过新建PostGIS插件,与SQL Server geometry, geography对应。

2.4、SQL Server , PostgreSQL , Oracle , MySQL 详细的开发者使用对比手册

https://www.w3resource.com/sql/sql-syntax.php

参考

https://github.com/dalibo/sqlserver2pgsql

https://www.codeproject.com/tips/1068276/convert-sql-server-database-to-postgresql

https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL#Microsoft_SQL_Server

https://wiki.postgresql.org/wiki/Microsoft_SQL_Server_to_PostgreSQL_Migration_by_Ian_Harding

http://www.postgresonline.com/journal/index.php?/archives/219-SQL-Server-to-PostgreSQL-Converting-table-structure.html

SQL Server 官方类型手册

https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-2016

PostgreSQL 官方类型手册

https://www.postgresql.org/docs/devel/static/datatype.html

空间类型通过新建PostGIS插件,与SQL Server geometry, geography对应。

SQL Server , PostgreSQL , Oracle , MySQL 详细的开发者使用对比手册

https://www.w3resource.com/sql/sql-syntax.php

Flag Counter

digoal’s 大量PostgreSQL文章入口