天天看點

PostgreSQL 與 MS SQL(SQL Server) 類型映射關系

标簽

PostgreSQL , ms sql , SQL Server , 類型映射

https://github.com/digoal/blog/blob/master/201808/20180818_03.md#%E8%83%8C%E6%99%AF 背景

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/digoal/blog/blob/master/201808/20180818_03.md#%E5%8F%82%E8%80%83 參考

https://github.com/dalibo/sqlserver2pgsql 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 官方類型手冊

PostgreSQL 官方類型手冊

空間類型通過建立PostGIS插件,與SQL Server geometry, geography對應。

SQL Server , PostgreSQL , Oracle , MySQL 詳細的開發者使用對比手冊