Oracle same table name on different schema?

2019-03-28 01:57发布

Is it possible to have same table name on different schema with different data on the tables within the one database? I think rather than create multiple database (that hold same table name) i should create multiple schema instead.

Something like:

Schema 1:
  table A, table B
Schema 2:
  table B, table X

PS: table B hold different data for each schema

And most basic question did every schema (user) hold different table set? In SQL Server and MySQL every user on same database have same table set, the difference was only on roles, how about Oracle?

Thanks

2条回答
forever°为你锁心
2楼-- · 2019-03-28 02:16

Yes this is possible. A schema in Oracle is what a MySQL user would call a database.

However, you need to be careful when accessing either of the tables now if the user you connect with to the database instance has access to both. To unambiguously reference a table in a specific schema, use schema.table.

查看更多
老娘就宠你
3楼-- · 2019-03-28 02:18

Here's the documentation on namespaces: http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/sql_elements008.htm#i27561

As jackrabbit says objects in different schemas have different namespaces.

Each schema in the database has its own namespaces for the objects it contains. This means, for example, that two tables in different schemas are in different namespaces and can have the same name.

Within a schema things are a little more complex.

Because tables and views are in the same namespace, a table and a view in the same schema cannot have the same name. However, tables and indexes are in different namespaces. Therefore, a table and an index in the same schema can have the same name.

查看更多
登录 后发表回答