PostgreSQL和MySQL之间的比较

对比表如下:

featuresPostgreSQLMySQL
Known asThe world’s most advanced open source databaseThe world’s most popular open source database
DevelopmentPostgreSQL is an open source projectMySQL is an open-source product
Pronunciationpost gress queue ellmy ess queue ell
LicensingMIT-style licenseGNU General Public License
Implementation programming languageCC/C++
GUI toolPgAdminMySQL Workbench
ACIDYesYes
Storage engineSingle storage engineMultiple storage engines e.g., InnoDB and MyISAM
Full-text searchYesYes
Drop a temporary tableNo TEMP or TEMPORARY keyword in DROP TABLE statementMySQL supports the TEMP or TEMPORARY keyword in the DROP TABLE statement that allows you to remove the temporary table only.
DROP TABLESupport CASCADE option to drop table’s dependent objects e.g., tables, views, etc.Does not support CASCADE option
TRUNCATE TABLEPostgreSQL TRUNCATE TABLE supports more features like CASCADE, RESTART IDENTITY, CONTINUE IDENTITY, transaction-safe, etc.MySQL TRUNCATE TABLE does not support CASCADE and transaction safe i.e,. once data is deleted, it cannot be rolled back.
Auto increment ColumnSERIALAUTO_INCREMENT
Analytic functionsYesNo
Data typesSupport many advanced types such as array, hstore, user-defined type, etc.SQL-standard types
Unsigned integerNoYes
Boolean typeYesUse TINYINT(1) internally for Boolean
IP address data typeYesNo
Set default value for a columnSupport both constant and function callMust be a constant or CURRENT_TIMESTAMP for TIMESTAMP or DATETIME columns
CTEYesNo
EXPLAIN outputMore detailedLess detailed
Materialized viewsYesNo
CHECK constraintYesNo (MySQL ignores the CHECK constraint)
Table inheritanceYesNo
Programming languages for stored proceduresRuby, Perl, Python, TCL, PL/pgSQL, SQL, JavaScript, etc.SQL:2003 syntax for stored procedures
FULL OUTER JOINYesNo
INTERSECTYesNo
EXCEPTYesNo
Partial indexesYesNo
Bitmap indexesYesNo
Expression indexesYesNo
Covering indexesYes (since version 9.2)Yes. MySQL supports covering indexes that allow data to be retrieved by scanning the index alone without touching the table data. This is advantageous with large tables with millions of rows.
Common table expression (CTE)YesNo
TriggersSupport triggers that can fire on most types of command, except for ones affecting the database globally e.g.,roles and tablespaces.Limited to some commands
PartitioningRANGE, LISTRANGE, LIST, HASH, KEY, and composite partitioning using a combination of RANGE or LIST with HASH or KEY subpartitions
Task SchedulepgAgentScheduled event
Connection ScalabilityEach new connection is an OS processEach new connection is an OS thread
Share

如果你觉得本文对你有帮助,可以请我喝杯咖啡。

好吧,请你喝一杯