You are on page 1of 6

6/13/2020 SQL Server, PostgreSQL, MySQL... what's the difference? Where do I start?

- DataCamp

Ishank Goel

Mona Khalil
October 15th, 2018

SQL

SQL Server, PostgreSQL, MySQL... what's the


difference? Where do I start?
In this tutorial, you'll learn some of the basic differences between SQL
dialects and where you should begin.

A relational database is a set of tables (datasets with rows and columns) that contain
information relating to other tables in the database.

The diagram below contains information about columns in two tables in an example
relational database. Both tables contain columns named customer_id, which establishes a
relationship between the tables. As the company grows and records thousands (or millions)
of orders, storing data in separate tables helps optimize for space and reduce the size of the
database.

SQL, or Structured Query Language, is the standard language for interacting with relational
databases. With SQL, you can query, or ask questions of, the data in a relational database.

https://www.datacamp.com/community/blog/sql-differences 1/6
6/13/2020 SQL Server, PostgreSQL, MySQL... what's the difference? Where do I start? - DataCamp

Working with SQL and relational databases is an invaluable skill set for a data analyst, data
engineer, or a data scientist.

If you have started looking for ways to learn SQL, you may have noticed the many different
dialects of SQL available to learn with some clear (and less clear) distinctions between the
different dialects. So where do you begin? Which version of SQL is most helpful to you if you
haven’t used it before? In this article, we will focus on four of the most popular database
management systems -- PostgreSQL, MySQL, SQLite, and SQL Server -- and their versions
of SQL syntax.

The graph below from Stack Over ow Trends provides a sense of how often each of these
platforms is discussed -- each line represents the percentage of all Stack Over ow questions
about each version of SQL.

MySQL has consistently been the most popular version of SQL in Stack Over ow questions.
Second in line is Microsoft SQL Server (including T-SQL, the name of Microsoft’s dialect of
SQL), which remains a consistently more popular tag than PostgreSQL and SQLite. This

https://www.datacamp.com/community/blog/sql-differences 2/6
6/13/2020 SQL Server, PostgreSQL, MySQL... what's the difference? Where do I start? - DataCamp

means that if you have a question speci c to one of these systems, you’re more likely to nd
that someone already asked your question.

What’s the difference?

PostgreSQL, MySQL, and SQLite use very similar syntax, with some notable differences
highlighted below. Microsoft SQL Server has the greatest contrast in SQL syntax, as well as a
wide variety of functions not available in other platforms. The table below highlights some
examples of basic differences between SQL platforms.

SQL Server MySQL PostgreSQL SQLite

Select [col1], SELECT col1, SELECT col1,


SELECT ... SELECT col1, col2
[col2] col2 col2

Yes WHERE Yes WHERE


No WHERE Yes WHERE name
Data from name = ‘John’ name = ‘John’
name = ‘John’ = ‘John’ Or
tables is Or WHERE Or WHERE
Or WHERE WHERE name =
case name = ‘john’ name = ‘john’
name = ‘john’ ‘john’ are not the
sensitive? are not the are not the
are the same same
same same

Using name = ‘John’ name = ‘John’


name = ‘John’
quotation or name = name = ‘John’ only or name =
only
marks “John” “John”

Aliases for SELECT SELECT


SELECT SELECT AVG(col1)
columns AVG(col1) AS AVG(col1) AS
AVG(col1)=avg1 AS avg1
and tables avg1 avg1

CURDATE() CURRENT_DATE()
Working GETDATE() DATE(‘now’)
CURTIME() CURRENT_TIME()
with dates DATEPART() strftime()
EXTRACT() EXTRACT()

Window
functions No (need to
i.e., use
Yes Yes Yes
OVER(), subqueries
PARTITION instead)
BY()

Where do I start?
https://www.datacamp.com/community/blog/sql-differences 3/6
6/13/2020 SQL Server, PostgreSQL, MySQL... what's the difference? Where do I start? - DataCamp

For students who have little to no experience with SQL and are looking to gain the most
broadly applicable skills, I recommend starting with PostgreSQL. Despite the overwhelming
popularity of MySQL, PostgreSQL may be a better choice because its syntax most closely
conforms to Standard SQL. This means that you can easily translate your skills to other
database management systems such as MySQL or SQLite. For example, the query below
aggregates data from a database of sales information. It contains a join, an aggregate
function, and a lter. This syntax will generate identical results in all three database systems.

Select
c.customer_name,
SUM(p.amount) AS total_sales
FROM customers AS c
LEFT JOIN purchases AS p
ON c.customers_id = p.customer_id
WHERE
c.customer_location = 'USA'
GROUP BY
c.customer_name;

If you anticipate working with Microsoft SQL Server in your career, I recommend you start
by learning T-SQL/Microsoft SQL. SQL Server continues to maintain a sizable market share
and is an important database management system in many industries. If you are unsure
which of these two is more important for you, I recommend browsing through job openings
in your eld to determine if there is a preference for a speci c database system in speci c
roles or industries.

How can DataCamp help?

At DataCamp, we currently offer two courses in SQL that cover introductory topics and joins
in PostgreSQL. We have some exciting courses in development covering intermediate and
advanced topics in PostgreSQL. We also have several SQL Server courses in development,
including an Introduction to T-SQL/Microsoft SQL course that will provide you with a clear
foundation for working with SQL Server. You can check out our course roadmap for more
information.

https://www.datacamp.com/community/blog/sql-differences 4/6
6/13/2020 SQL Server, PostgreSQL, MySQL... what's the difference? Where do I start? - DataCamp

If you’re looking to practice interacting with a PostgreSQL database on your own, I


recommend exploring data sets on Kaggle. If you nd something that interests you, go ahead
and import into PostgreSQL (CSV or SQLite les will import into PostgreSQL) and start
exploring!

Come teach with us!

Are you interested in sharing your knowledge and expertise with our 3 million students on
DataCamp? We are always looking for instructors to contribute to our growing course
library. Our course wishlist highlights the skills we are hoping to make available to our
students in the coming months. You can apply here at this link. We look forward to working
with you!

21 4

COMMENTS

Jon Nickerson
21/02/2019 04:27 PM

Loving the new SQL focus. 

SQL is used the most and talked about the least - which gives newcomers the wrong  skillset
expectations!

Visakh Vijayan
14/04/2019 09:05 PM

The article didn't mention the differences actually. How do you choose PostgreSql over Mysql?
What will you look out for?

Wojciech Hojdysz
22/11/2019 06:01 PM

The differences rows under SQL Server are mostly wrong. The brackets around columns in the
SELECT statement are optional. Data from tables is NOT case sensitive and the aliases for
columns throws an error when you run that as an alias for an average. SQL Server has the same
alias syntax as the rest.
https://www.datacamp.com/community/blog/sql-differences 5/6
6/13/2020 SQL Server, PostgreSQL, MySQL... what's the difference? Where do I start? - DataCamp

Austin H.
14/02/2020 08:46 AM

Wojciech- In my experience you are correct. I was never taught to use brackets in SELECT
statements in SQL Server. The only exception was when I was using aliases. Great call out.

For instance, the SQL Server SELECT statement above could be written:  

SELECT col1, col2  

Or 

 Select col1, col2 

Subscribe to RSS

About Terms Privacy

https://www.datacamp.com/community/blog/sql-differences 6/6

You might also like