Reputation: 11
I'm trying to grant all to scott on emp from SYS, but oracle
throwing ORA-00942: table or view does not exist
error message. I'm not even getting emp table details in sys
as dba
.
How can I grant all permission to scott so that I can create views or user in scott. When I tried to create a view or user in scott, system is throwing insufficient privileges
error message.
Thanks for your help.
Upvotes: 0
Views: 2918
Reputation: 146179
The EMP table is a venerable object, used in many old tutorials and blog posts. However, it is not built by default any more.
If you want EMP in a schema (and traditionally SCOTT is its owner) you need to run the build script. Where you'll find it depends on the precise version of the database, but it might be under the sqlplus/demo
sub-directory. On my Linux 11gR2 build it's at
%ORACLE_HOME/rdbms/admin/utlsampl.sql
OraFAQ has lots more about the SCOTT schema. Check it out.
On the other hand, if you want to use the modern demo schema (HR, SALES, etc) which are referenced in the current documentation, you will find all the scripts under:
%ORACLE_HOME/demo/schema
The documentation has installation instructions. Find out more.
Upvotes: 1
Reputation: 30765
You're having (at least) three different problems:
EMPLOYEES
, not EMP
EMPLOYEES
table is in the HR
schema, not in the SYS
schemaHR.EMPLOYEES
To fix these:
-- connect as SYS
GRANT CREATE VIEW TO scott;
-- connect as HR
CREATE SELECT ON employees TO scott;
-- connect as SCOTT
CREATE VIEW v_scott AS SELECT * FROM hr.employees;
UPDATE
If you're unsure about the correct table name, you can use this query to get a list of all tables in the database whose names start with EMP
(to run this, you'll have to use a privileged user account, e.g. SYS):
select owner, table_name from dba_tables where table_name like 'EMP%'
Upvotes: 1