Ing Data Types Between PostgreSQL and SQL Server

Source: Internet
Author: User
ArticleDirectory
    • Preface
Preface

PostgreSQL 8.1 was launched. I plan to migrate some SQL server applications to PostgreSQL. The first thing I need to migrate is tables, therefore, we must first figure out the ing relationship between the data types in the two databases. I checked the PostgreSQL documentation and made the following table to help you.

 

SQL Server 2000 Microsoft Jet-SQL 4.0 PostgreSQL 8.x
Bigint Decimal Bigint
Binary (N) Binary (N) Bytea (N)
Bit Bit Boolean, bool
Char (N) Char (N) Char (N)
Datetime Datetime Timestamp (date, time)
Decimal Decimal Decimal
Float Float Real, float4
Image Image Bytea
Int Int Integer, Int, int4
Money Currency Decimal
Nchar (N) Nchar (N) Char (N)
Ntext Longtext Text
Numeric Decimal Numeric
Nvarchar (N) Nchar varying (N) Varchar (N)
Real Real Real
Smalldatetime Datetime Timestamp (date, time)
Smallint Smallint Smallint, int2
Smallmoney Currency Decimal
Text Longtext Text
Timestamp Binary None
Tinyint Byte None
Uniqueidentifier Guid None
Varbinary (N) Varbinary (N) Bytea (N)
Varchar (N) Varchar (N) Varchar (N)

Note:The money (currency) Data Type in PostgreSQL is now obsolete and can be replaced by numeric or decimal and the to_char function.

* In SQL ServerDatetime,SmalldatetimeThe data type contains the date and time sections. The difference is that the precision is different. It corresponds toTimestampType (including date and time ). In PostgreSQL, if you only need the date part, you can useDateType, but only time is required.TimeType.

* In PostgreSQLBytea(N) Is always a variable binary byte array, which is equivalentVarbinary(N), If not specifiedByteaThe maximum number of bytes is an unlimited length variable byte array, which is equivalentImageData type.

* The character types in PostgreSQL are not different from those in SQL Server for local text and international text, whether the text data stored in PostgreSQL is internationalized or localized depends on the text encoding settings of the database.
To ensure the internationalization of data storage, we recommend that you set the text encoding method of the database to UTF-8 or Unicode to ensure that the stored text can be viewed and stored by users in different regions and cultures.

* For guid-type data, you can useBytea(16) To save the data. You can use byte array functions to compare the data.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.