Skip to content

Files

Latest commit

Dec 15, 2023
f400df2 · Dec 15, 2023

History

History
187 lines (68 loc) · 4.93 KB

20180818_03.md

File metadata and controls

187 lines (68 loc) · 4.93 KB

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

作者

digoal

日期

2018-08-18

标签

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


背景

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

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.

digoal's wechat