postgresql 将t-sql(SQL Server)存储过程转换为pgsql(postgre sql)的工具

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6952922/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-20 23:11:48  来源:igfitidea点击:

Tool to convert t-sql (SQL Server) stored procedure to pgsql (postgre sql)

tsqlpostgresqlautomation

提问by Prashant Lakhlani

Can anybody suggest a tool or share code which can help me converting large number of t-sql stored procedures in database to postgresql while migrating from SQL Server database to postgresql?

任何人都可以建议一种工具或共享代码来帮助我在从 SQL Server 数据库迁移到 postgresql 时将数据库中的大量 t-sql 存储过程转换为 postgresql 吗?

== Edited== here are some clear goals:

== 编辑== 这里有一些明确的目标:

  1. Convert all sps to postgre sql without considering performance / tuning etc, by only focusing that syntax is right and query returns correct data
  1. 将所有 sps 转换为 postgre sql 而不考虑性能/调优等,只关注语法正确并且查询返回正确的数据

Language conversion and transformation related guidelines are really useful. I see couple of old vbscript examples (most of them not working for me) and could try to convert them to T4 templates.

语言转换和转换相关的指南非常有用。我看到了几个旧的 vbscript 示例(其中大多数对我不起作用)并且可以尝试将它们转换为 T4 模板。

I am surprised no one really needed this kind of conversion! I still don't have a right tool to do so.

我很惊讶没有人真的需要这种转换!我仍然没有合适的工具来这样做。

Thanks in advance.

提前致谢。

采纳答案by Jan Marek

Have you seen this page:

你有没有看到这个页面:

Convert from other databases to PostgreSQL?

从其他数据库转换到 PostgreSQL?

回答by Ira Baxter

Translating languages is hard. You need to parse the original (with all the strange syntax and warts it allows above and beyond what the documentation says), determine what names mean, discover the semantics, and translate to the target language without losing the subtle details.

翻译语言很难。您需要解析原文(包括所有奇怪的语法和它允许的超出文档所说的内容),确定名称的含义,发现语义,并在不丢失微妙细节的情况下翻译成目标语言。

I'd be surprised if you found a solution for this off-the-shelf. Part of the problem is there are a vast number N of source languages (made worse by dialects), and a vast number of targets M, requiring a library of NxM translators to be lying around. And if you wait a few months, N and M both move. One hope is to translate N langauges to a common universal core language, and translate that to M targets, now only requiring N+M... but nobody has found a really universal language, and if you wait a few months, N and M move anyway.

如果您找到了针对此现成的解决方案,我会感到惊讶。部分问题在于有大量 N 种源语言(因方言而变得更糟)和大量目标 M,需要 NxM 翻译库。如果你等几个月,N 和 M 都会移动。一个希望是把N种语言翻译成通用的通用核心语言,再翻译成M个目标,现在只需要N+M……但是没有人找到真正通用的语言,如果你等几个月,N和M无论如何移动。

One can consider building (or getting someone else to build) a specific translator for the task; this usually is uneconomical, at least if you want it to be reliable, because so much of the translator machinery (parsing, name resolution, pattern matching/translating, ...) tends to get rebuilt from scratch.

可以考虑为该任务构建(或让其他人构建)特定的翻译器;这通常是不经济的,至少如果您希望它可靠,因为很多翻译机制(解析、名称解析、模式匹配/翻译,...)往往会从头开始重建。

One can amortize the cost of the translator infrastructure if you are careful, by building (a lot of) shared machinery. Once you do that, building a translator is easier (still not easy) and the economics make more sense for individual cases. You can read more about this approach at: What kinds of patterns could I enforce on the code to make it easier to translate to another programming language?

如果您小心的话,可以通过构建(大量)共享机器来分摊翻译器基础设施的成本。一旦你这样做了,构建翻译器就更容易了(仍然不容易),而且经济学对个别案例更有意义。您可以在以下位置阅读有关此方法的更多信息:我可以对代码实施哪些类型的模式以使其更容易转换为另一种编程语言?

回答by Alex_L

I'm sure that every SP needs to be converted by developers. Ira Baxter says (absolutelly correct) about languages, but I want to say about platform differences. for example, how to translate to different platform the usage temporary tables? What to do with performance-tuned queries? Performance tuning uses the specific features of RDBMS, and this tuning cannot be automatically converted. And so on...

我敢肯定,每个SP都需要开发人员进行转换。Ira Baxter 说(完全正确)关于语言,但我想说的是平台差异。例如,如何将用法临时表转换到不同平台?如何处理性能调优查询?性能调优使用了 RDBMS 的特定特性,并且这种调优不能自动转换。等等...