Differences between Database and Schema using different databases?

后端 未结 4 643
予麋鹿
予麋鹿 2020-12-23 14:17

What are the differences in database terminology between MS SQL and MySQL?

Can a MySQL instance have more than one database? It appears that it can only create diffe

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-23 14:27

    In general, I found the following article on Wikipedia to be useful.

    At the bottom of the article is the following:

    The SQL specification makes clear what an "SQL schema" is; however, different databases implement it incorrectly. To compound this confusion the functionality can, when incorrectly implemented, overlap with that of the parent-database. An SQL schema is simply a namespace within a database, things within this namespace are addressed using the member operator dot ".". This seems to be a universal amongst all of the implementations. A true fully (database, schema, and table) qualified query is exemplified as such: select * from database.schema.table

    Now, the issue, both a schema and a database can be used to isolate one table, foo from another like named table foo. The following is pseudo code: select * from db1.foo vs. select * from db2.foo (no explicit schema between db and table) select * from [db1.]default.foo vs. select * from [db1.]alternate.foo (no explicit db prefix) The problem that arises is that former MySQL users will create multiple databases for one project. In this context MySQL databases are analogous in function to Postgres-schemas, insomuch as Postgres lacks off-the-shelf cross-database functionality that MySQL has. Conversely, Postgres has applied more of the specification implementing cross-table, cross-schema, and then left room for future cross-database functionality. MySQL aliases behind the scenes, schema with database, such that create schema, and create database are analogs.

    It can be said, that MySQL therefore, has implemented cross-table functionality, skipped schema functionality entirely and provided similar functionality into their implementation of a database. In summary, Postgres fully supports schemas, but lacks some functionality MySQL has with databases, while MySQL doesn't even attempt to support true schemas.

提交回复
热议问题