Oracle在不同架构上使用相同的表名?

时间:2021-08-21 16:36:40

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?

而最基本的问题是每个架构(用户)都持有不同的表集吗?在SQL Server和MySQL中,同一个数据库中的每个用户都有相同的表集,区别仅在于角色,Oracle如何?

Thanks

谢谢

2 个解决方案

#1


8  

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

是的,这是可能的。 Oracle中的模式是MySQL用户称之为数据库的模式。

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.

但是,如果与数据库实例连接的用户可以同时访问这两个表,则在访问任一表时需要小心。要明确引用特定模式中的表,请使用schema.table。

#2


6  

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

这是关于命名空间的文档: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.

由于表和视图位于同一名称空间中,因此同一模式中的表和视图不能具有相同的名称。但是,表和索引位于不同的名称空间中。因此,同一模式中的表和索引可以具有相同的名称。

#1


8  

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

是的,这是可能的。 Oracle中的模式是MySQL用户称之为数据库的模式。

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.

但是,如果与数据库实例连接的用户可以同时访问这两个表,则在访问任一表时需要小心。要明确引用特定模式中的表,请使用schema.table。

#2


6  

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

这是关于命名空间的文档: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.

由于表和视图位于同一名称空间中,因此同一模式中的表和视图不能具有相同的名称。但是,表和索引位于不同的名称空间中。因此,同一模式中的表和索引可以具有相同的名称。