CREATE TABLE to another OWNER/SCHEMA and in a different TABLESPACE?
I am connected to a user of the SYSTEM. Now, I want to create a table of aaa. The owner of this table should not be SYSTEM but user KARL. and STORAGE space should not be SYSTEM but the tdtc TABLESPACE (existing).As far as I know I can do this by running the following command:
CREATE TABLE KARL.aaa (an INTEGER,...) Tttt TABLESPACE;
Regarding the TABLESPACE parameter, I'm not sure. Is it possible to return a user Karl TABLE in a TABLESPACE that is not assigned to him?
In addition, I have another problem.
I have a script with hundreds of CREATE TABLE, ALTER TABLE + CREATE INDEX DDL statements.
Each of them are not prefixed with schema/owner and a TABLESPACE clause.
I can put a single statement at the top of the script somehow that such Oracle
to use
-Karl OWNER as a schema/owner for all DDL stements
-Thomas TABLESPACE as TABLESPACE for all DOF stements
?
In MYsql, there is a statement «use < database >» Is soemthing similar to Oracle?
Thank you
Peter
Yes... you can do. For example, a user who has a secret password that you do not want to give... as a schema of the application. User B needs to make paintings/objects in A schema and you want to follow this as user B. First configure Oracles Fine grain auditing and then grant "connect via" user A to user B as follows:
-----
SQL> create user b identified by abc123
2 quota unlimited on users;
User created.
SQL> grant create session to b;
SQL> create user a identified by abc123
2 quota unlimited on users;
User created.
SQL> grant create table
2 , create session
3 to a;
Grant succeeded.
SQL> alter user a grant connect through b;
User altered.
SQL> connect b[a]/abc123@a486
Connected.
SQL> show user
USER is "A"
SQL> create table a.my_proxy_table
2 ( c1 number
3 , c2 varchar2(50)
4 , c3 date
5 );
Table created.
-----
See I have connected using the syntax "username [proxyuser]." Also note that user B is by proxy user has, as evidenced by my order 'show user '. The connection through can be granted/revoked as needed without disclosing A goes to B. In addition, your audit tables or xml logs will follow the fact that user B created the table a.my_proxy_table.
Hope this helps,
John
Tags: Database
Similar Questions
-
flow of Installer for tables with source schemas and destination is different
How to set up courses of water for tables with source schemas and destination is different? But the structure of the table is the same.
Please paste a small example too.
Thank you
BalaHello
I have a concrete example of this issue, I tested in my environment. Please follow the steps below to install this on your databases.
My global_name to database source is: REP102A. WORLD
My global_name to database target is: REP102B. WORLDSource table: ORDERS. ORDER_ENTRY
Target Table: MERCHANT NAVY. ORDER_ENTRYReplication will happen as follows:
ORDERS. ORDER_ENTRY (REP102A)-> SHIPPING. ORDER_ENTRY (REP102B)Needs to follow the steps below as the one proposed at each site. You may need to make the changes required for your environment.
SCRIPT:
=======* 1. Remove the configuration of the flow of SOURCE and TARGET sites: *.
CONNECT / as SYSDBA
RUN DBMS_STREAMS_ADM. REMOVE_STREAMS_CONFIGURATION;
DROP USER CASCADE STRMADMIN;* 2. Installation STRMADMIN user and streams queued on the Source database: *.
CONNECT / as sysdba
Strmadmin CREATE USER IDENTIFIED BY strmadmin;
GRANT dba, connect, resource, aq_administrator_role to strmadmin;
ALTER SYSTEM SET aq_tm_processes = 1;
BEGIN
DBMS_STREAMS_AUTH. () GRANT_ADMIN_PRIVILEGE
dealer-online "strmadmin."
grant_privileges => TRUE);
END;
/CONNECT strmadmin/strmadmin
BEGIN
DBMS_STREAMS_ADM. () SET_UP_QUEUE
queue_table-online "streams_queue_table."
queue_name-online "streams_capture_queue."
queue_user-online "strmadmin");
END;
/* 3. Installation STRMADMIN user and streams queued to the database target: *.
CONNECT / as sysdba
Strmadmin CREATE USER IDENTIFIED BY strmadmin;
GRANT dba, connect, resource, aq_administrator_role to strmadmin;
ALTER SYSTEM SET aq_tm_processes = 1;
BEGIN
DBMS_STREAMS_AUTH. () GRANT_ADMIN_PRIVILEGE
dealer-online "strmadmin."
grant_privileges => TRUE);
END;
/CONNECT strmadmin/strmadmin
BEGIN
DBMS_STREAMS_ADM. () SET_UP_QUEUE
queue_table-online "streams_queue_table."
queue_name-online "streams_apply_queue."
queue_user-online "strmadmin");
END;
/* 4. Create ORDERS. ORDER_ENTRY Table on the Source database: *.
CREATE USER controls IDENTIFIED BY;
GRANT connect, resource TO arrested;
CONNECT orders/ordersCREATE THE ORDERS TABLE. ORDER_ENTRY
(
order_id number (8) primary key,.
ORDER_ITEM varchar2 (30),
ship_no number (8)
);* 5. Create shipping. Target ORDER_ENTRY Table on the database: *.
CREATE USER IDENTIFIED BY expedition expedition;
GRANT connect, navigation resources;
CONNECT shipping/deliveryCREATE TABLE EXPEDITION TO FRANCE. ORDER_ENTRY
(
order_id number (8) primary key,.
ORDER_ITEM varchar2 (30),
ship_no number (8)
);* 6. On the target, add the rules to apply and create a dblink from destination to source: *.
CONNECT strmadmin/strmadmin
SET SERVEROUTPUT ON
DECLARE
v_dml_rule VARCHAR2 (80);
v_ddl_rule VARCHAR2 (80);
BEGIN
DBMS_STREAMS_ADM. () ADD_TABLE_RULES
table-name => ' EXPEDITION. ORDER_ENTRY',.
streams_type-online "apply."
streams_name-online "streams_apply."
queue_name-online "strmadmin.streams_apply_queue."
include_dml to-online true.
include_ddl-online fake,
include_tagged_lcr-online fake,
source_database => ' REP102A. WORLD ',.
dml_rule_name-online v_dml_rule,
ddl_rule_name-online v_ddl_rule,
inclusion_rule-online true);
DBMS_OUTPUT. Put_line (' apply rule DML for SHIPPING.) ORDER_ENTRY => ' | v_dml_rule);
END;
/CREATE DATABASE LINK rep102a.world CONNECT TO strmadmin IDENTIFIED BY strmadmin USING 'rep102a ';
-check the link works with:
SELECT * from [email protected];BEGIN
DBMS_APPLY_ADM. () ALTER_APPLY
apply_name-online "streams_apply."
apply_user-online "strmadmin");
END;
/* 7. The source adds the rules of capture, transformation, create a database link for target, add spread rules, then prepare the tables for instantiation: *.
CONNECT strmadmin/strmadmin
SET SERVEROUTPUT ON
DECLARE
v_dml_rule VARCHAR2 (80);
v_ddl_rule VARCHAR2 (80);
BEGIN
DBMS_STREAMS_ADM. () ADD_TABLE_RULES
table-name => ' ORDERS. ORDER_ENTRY',.
streams_type-online "capture."
streams_name-online "streams_capture."
queue_name-online "strmadmin.streams_capture_queue."
include_dml to-online true.
include_ddl-online fake,
include_tagged_lcr-online fake,
source_database => ' REP102A. WORLD ',.
dml_rule_name-online v_dml_rule,
ddl_rule_name-online v_ddl_rule,
inclusion_rule-online true);
DBMS_OUTPUT. Put_line ('Capture DML rule for ORDERS.) ORDER_ENTRY => ' | v_dml_rule);
-Add the schema to rename it to change ORDERS to NAVIGATION for this rule
DBMS_STREAMS_ADM. () RENAME_SCHEMA
nom_regle-online v_dml_rule,
from_schema_name-online "ORDERS."
to_schema_name-online 'EXPEDITION. "
operation => "ADD");
END;
/CREATE DATABASE LINK rep102b.world CONNECT TO strmadmin IDENTIFIED BY strmadmin USING 'rep102b ';
-check the link works with:
SELECT * from [email protected];-post-harvest enqueues the LCR will have schema as EXPEDITION via renamed of schema processing
-then add the rule of propagation for SHIPPING. ORDER_ENTRYSET SERVEROUTPUT ON
DECLARE
v_dml_rule VARCHAR2 (80);
v_ddl_rule VARCHAR2 (80);
BEGIN
DBMS_STREAMS_ADM. () ADD_TABLE_PROPAGATION_RULES
table-name => ' EXPEDITION. ORDER_ENTRY',.
streams_name-online "streams_prop."
source_queue_name-online "strmadmin.streams_capture_queue."
destination_queue_name-online "[email protected]."
include_dml to-online true.
include_ddl-online fake,
include_tagged_lcr-online fake,
source_database => ' REP102A. WORLD ',.
dml_rule_name-online v_dml_rule,
ddl_rule_name-online v_ddl_rule,
inclusion_rule to-online true.
queue_to_queue-online fake);
DBMS_OUTPUT. Put_line ("rule DML of Propagation for SHIPPING. ORDER_ENTRY => ' | v_dml_rule);
END;
/BEGIN
DBMS_CAPTURE_ADM. () PREPARE_TABLE_INSTANTIATION
table-name => ' ORDERS. ORDER_ENTRY',.
SUPPLEMENTAL_LOGGING-online 'key');
END;
/* 8. Set the instantiation scn for ORDERS. ORDER_ENTRY on the site target and start apply: *.
-Apply on site
CONNECT strmadmin/strmadmin
SET SERVEROUTPUT ON
DECLARE
iSCN NUMBER;
BEGIN
iSCN: = DBMS_FLASHBACK. [email protected] ();
DBMS_OUTPUT. Put_line (' instantiation SCN is: ' | iSCN);
DBMS_APPLY_ADM. () SET_TABLE_INSTANTIATION_SCN
source_object_name => ' ORDERS. ORDER_ENTRY',.
source_database_name => ' REP102A. WORLD ',.
instantiation_scn-online iSCN,
apply_database_link => NULL);
COMMIT;
END;
/BEGIN
DBMS_APPLY_ADM. START_APPLY ('streams_apply');
END;
/-Check if apply is enabled
SELECT apply_name, dba_apply State;* 9. Start capturing on source: *.
CONNECT strmadmin/strmadmin
BEGIN
DBMS_CAPTURE_ADM. START_CAPTURE ('streams_capture');
END;
/* 10. Wait capture change its status of 'CAPTURER the CHANGES' and check that the status of propagation is ENABLED: *.
CONNECT strmadmin/strmadmin
SELECT capture_name, State FROM v$ streams_capture;
SELECT propagation_name, dba_propagation State;* 11. Perform inserts in ORDERS. Table ORDER_ENTRY on the source site: *.
CONNECT orders/orders
INSERT INTO orders.order_entry VALUES (23450, 'Johnny Walker', 98456);
INSERT INTO orders.order_entry VALUES (23451, "Chivas Regal", 98457);
COMMIT;* 12. On the site apply, check the DELIVERY. ORDER_ENTRY and check if the data is replicated: *.
CONNECT shipping/delivery
SELECT * FROM shipping.order_entry;* 13. Check the application errors in the queue to apply: *.
CONNECT strmadmin/strmadmin
SELECT apply_name, local_transaction_id, error_number, error_message FROM dba_apply_error;Thank you
Florent -
After spending tables and index a different tablespace, index got unusable?
Hello
I moved to table and index a different tablespace. After the many indices obtained unusable. I did not understand thiis?
How can I do still usable?
best regards and thank you?If you bâtait the index (after moving the table, by the way), then they should be usable without something extra to see.
Check this procedure only one (small) table and index if this index can be used later. If not, then you have a mystery :-)Kind regards
Uwe Hessehttp://uhesse.WordPress.com
-
Create table form another table in different schema throwing error when dynamic sql
Hello
With the help of 11.2.0.3 and was following the issue.
To create a table in a schema (b) using data from another schema (b)
If independent run in sqlplus create works OK but same sql in dynamic sql block saying the table or view does not exist.
SQL even in dynamic sql
{code}
v_sql: =' create table new_table in select * from schemab.table_name where...';
run immediately (v_sql);
[code}
Other tables work fine.
Any ideas - don't want to grant all the schemaa.table schema b if can avoid.
Thank you
You run the immediate execution in an anonymous block or a stored procedure? If it is a stored procedure, then as others have said, the owner of the procedure must have select privileges on granted directly schemab.table_name.
Another possibility, which would be the case for a stored procedure, or an anonymous block is that your code is something like:
v_sql: =' create table new_table in select * from schemab.table_name where...';
immediately run v_sql;
Select count (*) in the l_count new_table;
who will fail at compile time because new_table does not exist.
When you create objects using dynamic sqly you dynamic sql user to reference them in the block of code.
John
-
Creating tables with the same Structure and with the remote control FOR the parts database
Hello
I have a remote DB connection and a local DB connection in my system
I want to create the same Table and data from my DB remote to Local Connection DB connection.
Please tell me how to do this?CREATE TABLE LOCAL_TABLE AS SELECT * FROM REMOTE_TABLE@TNS_ALIAS;
-
How to add the new model feature with tables of another data schema?
Hi all
I am trying to add an entity data model to my request. The tables I need are on a schema that does NOT have a default schema of connection of the connection. So I go through the Wizard add new Entity Data Model, generation from database, but then when it comes time to choose your database objects, the only thing that shows is all that is on the default schema. How can I access stuff to another schema with an entity data model?
(Tangentially: it is also a problem with the old Server Explorer simply itself - when adding an oracle db, I see the other schema object in the treeview control to break.) But when I right click the db and the new query, tables of other scheme become available to me here. "So it is less of a problem in the case of Server Explorer).
I found this small excerpt to reach other patterns, but I couldn't make it work in the case of the ora db. Any suggestions?
Thanks for the tips,
-sffSuppose that schema_a has granted privileges to schema_b on database belonged to schema_a objects by running the GRANT statements.
You add a connection in Server Explorer using schema_b, and then add the schema_a in the "Filters" menu... ». Don't forget to click on
the button of update in "Filters" dialog box and confirm schema_a illustrated with schema_b in the column 'value '.When to use EDM Wizard to create a database data model, choose the connection that you added by using Server Explorer
schema_b. You will see the database of objects belonging to both schema_b and schema_a select and generate your data model. Schema_b
should be able to use the database objects belonged to schema_a according to the privileges granted. -
Create tables custom wwww in schema Apps (what are the problems with this?)
Hi all
I'm a dba in a new environment where a number of custom diagrams is created in the schema of apps. I know that this is not considered the best practices of Oracle and I would like to make some recommendations for a change. Before that, I would like to know the problems that are associated with custom tables, living in the apps schema. We're currently on 11.5.10.2 on AIX. Also, if anyone can point me to the 'Official' standard customization or Oracle documentation where can I back up my case it would be greatly appreciated.
Thanks in advance,Hello
Please see this thread.
Custom application implemented in E-bussiness Suite
Re: Custom application is implemented in E-bussiness SuiteKind regards
Hussein -
Question about GRANT CREATE TABLE permission
Hello
How can I give UserA to create tables to UserB/SchemaB. I understand that 'CREATE TABLE' will give permission to the user to create tables within its own schema and "CREATE ANY TABLE" will give permission to the user to create tables in a schema.
Y at - it a command to give the specific schema CREATE TABLE? Please advice... Thank you!Y at - it a command to give the specific schema CREATE TABLE? Please advice... Thank you!
No, but you can create your own solution
have SCHEMA_B create a procedure, MAKE_SCHEMA_B_TBL, which sends the command below
RUN IMMEDIATELY CREATE TABLE...
then do as below
GRANT EXECUTE ON MAKE_SCHEMA_B_TBL TO SCHEMA_A;
-
Could someone help me please as to what's wrong in the creation under the structure of the table:
create table test (select * from schema.tablename where 1 = 2)
TABLESPACE PCR_ARCHIVE_DATA_04
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE)
64K INITIALS
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
DEFAULT USER_TABLES
)
NOLOGGING
COMPRESS
NOCACHE
PARALLEL (INSTANCES OF 6 1 DEGREE)
MONITORING;SELECT AS comes after the physical attributes, such as
create table test TABLESPACE PCR_ARCHIVE_DATA_04 PCTUSED 0 PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0 BUFFER_POOL DEFAULT ) NOLOGGING COMPRESS NOCACHE PARALLEL ( DEGREE 6 INSTANCES 1 ) MONITORING as (select * from schema.tablename where 1=2)
Best regards
Maxim
-
create existing table in another schema
Hi master,
We are using oracle 10g R2 on linux.
I have a scheme say user1 with many tables, starting with
BC_ (50 PICTURES)
PC_ (20 TABLES)
LC_ (30 TABLES) etc.,.
now, I want to create these tables in another schema with their constraints and their privileges in another schema.
as I want to generate a create table script, which will create a table that begins with "BC_" only. another script will create table starting with "PC_" only. and like that.
is it possible with the command
create the table AS
Select * from (old scheme). (table_name);
can we use query sub in it to be more precise?
and it will transfer all its privileges and grants the new schema?
Thanks and greetings
VDIt is possible to CREATE TABLE as SELECT from a different scheme but CREATE TABLE as SELECT will transfer only the data and the structure of the base (column names and data types) table, no constraints.
I think, you have two options to do this easily:
(1) use SQLDeveloper (GUI) or a procedure from PL/SQL DBMS_METADATA. GET_DDL to generate the SQL script to create table with constraints, you can use INSERT INTO new table (columns) column SELECT FROM oldschema.oldtable
DBMS_METADATA Description: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_metada.htm#i1019414(2) export a schema data, import it into the other using Data Pump or exp/IMP.
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14215/dp_export.htm#i1007466 -
Creating table in the schema has with the user B and granting permissions to the user C
Hello, I have a problem fun - we have a large table which requires a batch to make millions of updates, and he needs to finish more quickly. It takes several hours as an update, but a select create table did the same thing in about a minute. Yay! Then we just delete the old table and rename the new table to the former, rebuild all the index and grant select/insert/update/delete permissions to another user who needs access... and there is the problem, Oracle said insufficient privs.
We have A figure, which is the owner of the table, userid B who done all the stuff of application batch and userid C which performs inserts for a process of middleware. None of them are actual users, of course. We want that user B to do the ETG, rename, rebuild and re-grant of the authorisation of the index. But user B apparently cannot grant permissions on objects in the schema A to user C, even if B has created the table and has the role DBA (not ideal, I know)!
What's really crazy is that there is no sense unique user b can grant permissions to user C, which is to:
grant select any table USER c;
grant insert any table USER c;
grant update any table USER c;
Grant delete any table USER c;
It seems really perverse can create tables in diagram A and even grant C privs "whole table" that user B, but may not grant privs specifically on this object in the schema A, even with DBA privs. I must be missing something... right?Yes. By default, the stored procedures are stored procedures from DEFINER rights. If A is the owner of a stored procedure, this stored procedure can do whatever A enjoys the privileges to directly. If A grants B privileges RUN this stored procedure, when B calls the stored procedure, the procedure runs with the privileges.
I agree point stew, however, re-creating objects in Oracle is generally a bad idea and a TRUNCATE with one insert direct-path, possibly combined with the deactivation and the rebuilding of the index would be more appropriate than a DEC. If you're going to stick with this Assignment, however, that really do in a stored procedure owned by A while B has no need to CREATE ANY TABLE.
Justin
-
Creating Index on another table in schema stored in my table
Hello
I want to create indexes on a table column that is in another schema of my schema and index will be stored in my diagram.
ex: the current user 'hr '.
SQL > create index idx1 on scott.emp (eno);
Does the above query?
Thank you
SriSQL> conn Enter user-name: hr@**** Enter password: Connected. SQL> create index ndx on scott.emp(sal); Index created. SQL> show user USER is "HR" SQL> select index_name from user_indexes where index_name = 'NDX'; INDEX_NAME ------------------------------ NDX
-
create table with references to values in another schema
Experts,
Is it possible to create the table in a schema with the references pointing to column values in a different pattern?
Say, I have 2 diagrams A and B
Has the employee table and and B dept table, I want to run him below modifies the declaration, it will work?
ALTER TABLE A.EMP ADD)
FOREIGN KEY (DEPT_ID)
REFERENCES B. DEPARTMENT (DEPT_ID));
I know there is no sense in doing this, still would like to know to make a temporary workaround solution.
Kind regards
LIBERATOR
Published by: manon on October 21, 2011 12:30 AMYes it is possible with the right privilege:
SQL> grant connect, resource to a identified by a; Grant succeeded. SQL> grant connect, resource to b identified by b; Grant succeeded. SQL> connect b/b Connected. SQL> create table p (x int primary key); Table created. SQL> grant references on p to a; Grant succeeded. SQL> connect a/a Connected. SQL> create table c (y int); Table created. SQL> alter table c add foreign key (y) references b.p(x); Table altered.
-
How to create the table in another schema of database even
Hello..
I have a database DB1
and 2 patterns / users in this...
Usr1 and Usr2...
I created a TEMP Usr1 schema table... and created
Then tried the following declaration in the schema Usr2...
CREATE TABLE TEMP AS SELECT * FROM Usr1.TEMP;
Then it is in error that...
: 00942 TABLE OR VIEW DOES NOT EXIST...
What is the reason for this...
Thank youYou must make this grant on any new table, you create in usr1 and you want to use in the usr2 schema.
Its not desirable, but you can give system privileges
grant select to usr2.
USR2 can select on any table.
-
Expdp tables a schema and all the objects in another schema
Hello
Is there a way we can export tables to a diagram and everything else a diagram? I tried below, but none of them did the job.
Table = A.Table1, A.table2
schemas = b, c
include = table: "in (a. 'Table1'., 'Table2')" "
schemas = b, c
Thank you
The datapump has several modes:
"Full import mode.
"Schema Mode".
"Table mode".
'Space Mode '.
"Transportable Tablespace mode."
It seems that datapump cannot be in one mode at a time.
So you have to choose the mode of table first, then for the following export select pattern mode.
Maybe you are looking for
-
Hand tool missing grabber in the mixer window?
In the logic of X, I can't find the tool at hand grabber in the mixer window. In previous versions, I would use it to move the bands of channels, or plugins autour. For example, if I wanted to change the processing order of the plugins, then I would
-
Cannot install Linux alongside Windows-8 (UEFI)
I have HP pavilion 23-b026 all in one PC, which came with pre-installed Windows-8. Now, I want to install Linux alongside W - 8. (There is unallocated space on the disk about 250 GB) But when I try to boot from Linux-DVD, BIOS allows system to be boo
-
Undeliverable message send my Outlook to the sender
I use Outlook Express and Window XP Professional for many years. Recently some of my clients have told me that they have received the message as written "this Message was delivered for the following reason: the user account (s) is temporarily off-co
-
Fix KB981013 self extractor PW invalid
I ask hoftix to KB981013 Vista Ultimate x 64 SP2I used this fix in the past without problems. (16/11/2010)I downloaded the file several times and even tried 3rd party extraction tool (7zip)but the password provided is invalid. To test other factors,
-
No Audio device detected received after upgrade to Vista message
NO AUDIO DEVICE NOT DETECTED - UPGRADE WINDOWS XP TO WINDOWS VISTA ULTIMATE Recently, I switched from Windows XP to Windows Vista Ultimate, and now I have no sound. No audio output device detected. I tried the driver far from Device Manager, still no