creating tables in another schema [message #60744] |
Tue, 02 March 2004 05:21 |
mohammed anwar ahmed
Messages: 1 Registered: March 2004
|
Junior Member |
|
|
Dear Sir,
I want to create tables in another users schema, for this I had granted the user with "create any table " system permission.
But when I granted this permission to a user, he is also able to create tables in system schema (system account).
I want to restrict the user from creating tables into system account, but he should be able to create tables in some of the required user accounts.
Thanks in advance. Waiting for a positive reply.
Regards,
Anwar.
|
|
|
Re: creating tables in another schema [message #60746 is a reply to message #60744] |
Tue, 02 March 2004 08:03 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
You need to do this with your own logic. Revoke the "create any table" priv. Try creating a stored procedure in the schema where you want to be able to create the table and grant execute on that to his account.
Try something like this:
create or replace procedure run_ddl (p_ddl in varchar2)
as
begin
execute immediate p_ddl;
end;
/
|
|
|
Re: creating tables in another schema [message #60747 is a reply to message #60744] |
Tue, 02 March 2004 08:37 |
Thiru
Messages: 1089 Registered: May 2002
|
Senior Member |
|
|
Also, you can do something like this..
SQL> create or replace trigger restrict_system
2 before create on DATABASE
3 when (ora_dict_obj_owner='SYSTEM' and user !='SYSTEM')
4 begin
5 raise_application_error(-20001,'You are not authorised!');
6 end;
7 /
Trigger created.
SQL> show user
USER is "SYSTEM"
SQL> create table system.t(x int);
Table created.
SQL> drop table t;
Table dropped.
SQL> connect scott/tiger
Connected.
SQL> select * from user_sys_privs;
USERNAME PRIVILEGE ADM
------------------------------ ---------------------------------------- ---
SCOTT CREATE ANY TABLE NO
SCOTT UNLIMITED TABLESPAC
SQL> create table system.t(x int);
create table system.t(x int)
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20001: You are not authorised!
ORA-06512: at line 2
SQL> create table scott.t2(x int);
Table created.
SQL> create table thiru.tc(x int);
Table created.
-Thiru
|
|
|