Re: Views and tables

  • From: Nigel Thomas <nigel.cl.thomas@xxxxxxxxxxxxxx>
  • To: cemail_219@xxxxxxxxxxx, Oracle-L Freelists <oracle-l@xxxxxxxxxxxxx>
  • Date: Mon, 16 Nov 2009 20:18:49 +0000

2009/11/16 J. Dex <cemail_219@xxxxxxxxxxx>
> Is it possible to create a view with the same name as a table in the same
schema without harming an application?


No it isn't. You can't have two identically named objects in the same
schema. How would the application know which object it was looking at?


C:\oraclexe\app\oracle\product\10.2.0\server\BIN>sqlplus testuser/testuser
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 16 20:10:02 2009
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

SQL> create table TV(F1 integer);

Table created.

SQL> create view TV as select * from dual;
create view TV as select * from dual
                                *
ERROR at line 1:
ORA-00955: name is already used by an existing object

(You can't create a procedure, package or function with that name either -
though you can create an index with the same name).

Of course, you can create a table X in schema A, and a view X in schema B,
and you could have an application running in schema C and then have the
application reference a synonym C.X which resolves to either A.X or B.X
(privileges permitting). But that's another story

Regards Nigel




>

Other related posts: