oracle>Recreate Lost DUAL table

202 views
Skip to first unread message

ExpertDba

unread,
Jun 8, 2005, 8:59:48 AM6/8/05
to ORACLE_DB...@googlegroups.com
I found this interesting post on another group.Read on itz nice:

I have dropped the Dual Table from database.. Wanted to re-create
it???..How
do I do this....(actually one must be insane to do this :+) )

Anyways a good expert answer follows:
Soln)
There is a view named x$dual, that is created when you run catalog.sql.
If this table have dropped the easiest way to create the table is:-

create view x_$dual as select * from x$dual ;
grant select on x_$dual to public;
connect my_schema_owner/mypassword;
create public synonym DUAL for sys.x_$dual ;

ExpertDba

unread,
Jun 9, 2005, 1:09:05 AM6/9/05
to ORACLE_DB...@googlegroups.com
You can create the same using ..

Create table dual as select dummy from x$dual;

See below for demo :
-------------------

SQL> show user
USER is "SYS"
SQL>
SQL> select owner,OBJECT_NAME,OBJECT_TYPE from dba_objects
2 where object_name like '%DUAL%'
3 /
OWNER OBJECT_NAME OBJECT_TYPE
---------- ------------------------------ ------------------
SYS DUAL TABLE
PUBLIC DUAL SYNONYM
2 rows selected.
SQL> select * from dba_synonyms where SYNONYM_NAME = 'DUAL'
2 /
OWNER SYNONYM_NAME TABLE_ TABLE_NAME DB_LINK
---------- ------------------------------ ------ ---------- ----------
PUBLIC DUAL SYS DUAL
1 row selected.
SQL> desc dual
Name Null? Type
----------------------------- -------- --------------------
DUMMY VARCHAR2(1)
SQL> select sysdate from dual;
SYSDATE
---------
08-JUN-05
1 row selected.
SQL> drop table dual;
Table dropped.
SQL> select sysdate from dual;
select sysdate from dual
*
ERROR at line 1:
ORA-00980: synonym translation is no longer valid

SQL> select sysdate from sys.dual;
select sysdate from sys.dual
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> create table sys.dual as select dummy from x$dual;
Table created.
SQL> GRANT SELECT ON Sys.Dual TO PUBLIC WITH GRANT OPTION;
Grant succeeded.
SQL> conn hr/hr <-- login in different schema to test the dual
SQL> desc dual
Name Null? Type
----------------------------- -------- --------------------
DUMMY VARCHAR2(1)
SQL> select sysdate from dual;
SYSDATE
---------
08-JUN-05
1 row selected.
SQL> select sysdate from sys.dual;
SYSDATE
---------
08-JUN-05
1 row selected.
SQL>

Reply all
Reply to author
Forward
0 new messages