Friday, December 31, 2010

The case of the missing table!!!

 Now that I had created a database 'abc' using dbca I decided to take create a little database to keep track of my favourite Bollywood movies.
-bash-3.2$ export ORACLE_SID=abc
-bash-3.2$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Dec 31 09:29:14 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table movies (
  2  id number,
  3  movie_name varchar2(30),
  4  actor varchar2(30),
  5  actress varchar2(30),
  6  year_released number
  7  );

Table created.

SQL>

SQL> insert into movies
  2  values ( 1, 'Sholay', 'Amitabh Bachchan', 'Hema Malini', 1975);

1 row created.

SQL>
SQL> insert into movies
  2  values (2, 'Khilona', 'Sanjeev Kumar', 'Mumtaz', 1970);

1 row created.

SQL>
SQL> insert into movies
  2  values (3, 'Chupke Chupke', 'Dharamendar', 'Sharmila Tagore',1975);

1 row created.


So now I want to know my table was really created, and if so on what tablespace

SQL> select owner, table_name, tablespace_name   2  from dba_tables   3  where table_name='movies'; no rows selected SQL>

What??? Where is my table??? Well Ok, don't forget we are working with Oracle, and that would have been too easy.

SQL> select owner, table_name, tablespace_name
  2  from dba_tables
  3  where table_name='MOVIES';

OWNER                          TABLE_NAME
------------------------------ ------------------------------
TABLESPACE_NAME
------------------------------
SYS                            MOVIES
SYSTEM

Yes!!! It's bloody case sensitive. Now why would they do that, and even it was, why would Oracle not fix it. Don't
ask cause we are dealing with Oracle out here.

Anyroad, the table has been created and it's in the SYSTEM tablespace

SQL> select table_name, tablespace_name
  2  from user_tables
  3  where table_name = 'MOVIES';

TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
MOVIES                         SYSTEM

No comments: