3

I am going through a course in Udemy that teaches SQL using PostgreSQL. Yesterday I wanted to solve some SQL questions on Hackerrank. But it does not have the option to write in PostgreSQL. It has options to write SQL using using DB2, MySQL, Oracle and MS SQL Server. Could you please advice which of these is nearest to PostgreSQL in terms of Syntax so that I can spend minimal time in re-skilling? Thanks.

1

MySQL queries are, in most cases, exactly the same as PostgreSQL queries. Like PostgreSQL, MySQL uses tables as a core component and has more or less the same feature set as PostgreSQL. If you just use basic SQL, then you will hardly notice any difference between PostgreSQL and MySQL.

2
1

There is a standard for the SQL language. That standard has grown and evolved over the years, with various editions published over decades.

Many databases claim to support various editions of the standard. However, no database has implemented all of the standard completely. And all databases extend the standard, adding commands and features beyond those defined in the standard. Every SQL database on the market is both a subset and a superset of the standard.

So your Question is impossible to answer. SQL is too vast and the database systems too diverse to make any kind of sensible conclusion about the closeness of similarity. All SQL database systems are quite similar to each other versus non-SQL databases, but they are also quite different. Learning about these differences, and learning to live with them, is just part of life if you intend to write portable code.

Postgres makes a priority of complying with the standard. And one can argue Postgres is one of the most compliant implementations of the standard. The documentation is quite good about describing aspects of the standard and then describing how Postgres does or does not implement those.

0

You can see a comprehensive comparison in SQL syntax between PostgreSQL and the four dialects offered by HackerRank at http://troels.arvin.dk/db/rdbms/.

Like PostgreSQL, MySQL syntax is fairly close to the SQL standard, but MySQL is missing features like outer joins and set minus. Also, until ~2017 it did not support WITH… AS… clauses, and the MySQL on HackerRank does not yet support it. There are workarounds for these missing features, such as unioning a left join with a right join to make an outer join, but they are not pleasant to use.

Microsoft SQL Server syntax is a bit more divergent from the SQL standard. I would recommend Oracle or DB2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.