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
VD

It 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

Tags: Database

Similar Questions

  • 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 you

    You 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.

  • As sysdba, how I would create a table in another schema of users

    Well, I'm a student so I may have some of the words wrong, but I think you understand what I mean.

    I am logged in as sysdba, I created a user named scott, and now I want to give the table scott. I want to leave sysdba, as in I don't want to login as scott.

    ALTER USER SCOTT QUOTA 100M ON USER01;

    CHANGE USER QUOTA UNLIMITED ON

  • READ the TABLE of another schema

    Hello
    pls help me.

    I want to read the table of another schema that is declared in the application of the apex.

    SELECT * FROM DBA_ROLE_PRIVS;
    (SELECT * FROM sys.) DBA_ROLE_PRIVS: auch bad)

    The owner of this table is SYS.

    Error: The Table is unknown or cannot be found.

    my real schema is GCs.

    How is the select statement for this case for reading in the table (or tableview) of another schema?
    many and many thanks for your help.
    TL

    The SYS schema is a special schema in Oracle. You must explicitly grant the user rights by selecting tables and views sys.

  • grant the select privilege on the table in another schema by role error

    Hello
    I have a problem with the granting of privileges to another schema
    I have A user who has only 1 system priv: connect, which has a private: create session;
    I created a role X, which I have the privilege: select on a table to a diagram B customer.
    I then conceded this X role to A user.
    I can't select * B.customers when im connected to A
    identification of information like it that I'm missing?
    Thank you
    Rgds

    >
    but whenever I put a default role, the other is automatically set to zero-defects

    How did you receive the two default roles?
    >
    By running the code I posted above as user SYS.

    Drop your user and start again and use the code I posted.

  • Update/insert into table in another schema

    Hello

    I have a custom table that is located in another schema used by our dashboard for custom tables. I want to allow users to add/edit users and the security groups for dashboards.

    I see two possible solutions to this issue, I was wondering if anyone has done so and has a better solution or pointers.

    Possible solutions:

    1. move the table to the APEX workspace. Not desirable, would lead to changes in the Production for the pools of connections in the repository.

    2. create a temporary table where you would load the security table data when the user wishes to add/modify records in the security table and then use triggers to update the table by using the synonym to the table.

    Any help would be appreciated.

    Thank you
    Rob

    Modify the procedure to look like to...

    create or replace PROCEDURE UPDATE_TABLE(p_table IN VARCHAR2,
                                             p_column IN VARCHAR2,
                                             p_value IN VARCHAR2,
                                             p_condition IN VARCHAR2)
    AS
    v_sql_stmt VARCHAR2(4000);
    BEGIN
      v_sql_stmt := 'UPDATE ' || p_table || '  SET ' || p_column || ' = ' || p_value || ' WHERE ' || p_condition;
      EXECUTE IMMEDIATE v_sql_stmt;
      COMMIT;
    END UPDATE_TABLE;
    
    {code}
    
    Edited by: Tyson Jouglet on Sep 25, 2008 8:03 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    
  • How to create a table in a schema in the SOA database

    Hello

    can you please guide me how to create a table looks under custom schema available in the SOA database

    Thank you

    Valsaint

    Hello

    1. use JDeveloper to connect to your schema custom: view > Database > Database Navigator > new connection

    2. set the mpdel of your table column names, types of data, constraints (primary key, not null, foreign key, etc..)

    3. use this simplified tutorial to create the table according to your model of table create statement - Oracle/PLSQL: CREATE TABLE statement

    4. execute the statement in the SQL of JDeveloper journal for the custom connection (point 1 above).

    Let me know if you need help!

    HTH,

    A.

  • How to allow a user to view all the tables from another schema?

    I have a 'vic4ever' scheme where I have created all my tables. Now, I create a new user named "nvvp1". So, I want to enable nvvp1 display all tables in a schema vic4ever. But I don't know how to do! Or I need to run this command for each table?
    Grant select on vic4ever.table1 to nvvp1;
    Grant select on vic4ever.table2 to nvvp1;
    ....

    Thank you

    Yes, that's what you have to do, but you could speed up a bit:

    BEGIN
    FOR cur_rec IN (SELECT table_name FROM ALL_TABLES WHERE UPPER(owner) = 'NVVP1')
      LOOP
        EXECUTE IMMEDIATE 'Grant select on vic4ever.' || cur_rec.table_name || ' to nvvp1';
      END LOOP;
    END;
    /
    
  • the display of tables in another schema in the database

    I started using the SQl Developer 1.5.
    We can connect to a database of oracle with success, expanding the tables, it displays the list of tables in a schema.

    We have another schema in the database. In the query Panel, when type us the name of the other schema as the CHT. then a few table names appear in the intellisense.


    How can show us the list of tables to another within the same database schema.

    Welcome.

    Please also take some time for correct/good answers to award points.

  • Referencing Tables in another schema

    APEX 4

    http://i.imgur.com/WDwSC.jpg

    Is it true that you cannot reference another schema objects (i.e. ONLY the scheme of the application's default analysis)?

    I also noticed that this button "Requester" will lead you to QB page where only the analysis scheme appears.

    Thank you

    RalphK,

    Not true. Make sure that your analysis schema has grants appropriate to perform the action you want on an object in another schema. If this is not enough and you need access to another scheme of your workspace and then talk to your apex admins and it adds the schema to your workspace. Workspaces can be mapped to multiple schemas. It is not a one to one relationship.

    Thank you

    Janet Tyson

  • create existing table table

    Hi all

    I created a table like - saving
    create table_bkp in select * from table_Ex;

    -are the indexes and partitions created for the backup also table here?

    I then dropped the oriignal table
    fall of table_Ex;

    Now if I want to re - create backup of original, is table table anyway to make sure that I get automatically also all my indexes and partitions back?

    Thank you

    Yes... .you can make partition for statement DEC...

    CREATE TABLE target_table
    PARTITION BY (...) PARTITIONS)
    AS SELECT * FROM source_table;

  • How to listen to a couple of times (with different names) table in another schema?

    Hello guys,.

    I replicate a table schema (SCH_1) (TAB_1) on the basis of data source (named DB_1) twice on the schema (SCH_2) on the basis of data target (DB_2) with two different names (TAB_1 and TAB_1_SHORT). TAB_1_SHORT on db target must be a subset (eg. WHERE STATUS = 1) of TAB_1!

    How to do? can someone help me?

    I tried to realize that in this way:

    (1) creation of 1 capture process with the rule 1 table on source db (without any rule of subset to capture all changes) for table TAB_1

    (2) creating a process of spreading with no rules

    (3) creation 1 apply the process with a rule in table for table TAB_1 without any subset_rule but with the transformation of the pattern of SCH_1 to SCH_2 (DBMS_STREAMS_ADM. RENAME_SCHEMA) = > it works correctly!

    (4) creating a subset_rule (WHERE STATUS = 1), a transformation of the pattern of SCH_1 to SCH_2 (DBMS_STREAMS_ADM. RENAME_SCHEMA) and a transformation of tablename from TAB_1 to TAB_1_SHORT (DBMS_STREAMS_ADM. RENAME_SCHEMA) for table TAB_1_SHORT = > does not work, no errors posted in dba_apply_error!

    in another chance, I tried to turn the table and the schemaname in the process of capture, with the effect that my first table TAB_1 would not be listened to again.

    I don't know what the problem is. I think it must be possible to publish a table for two different targettables in the same pattern on an another db, is not it?

    I hope that the greetings
    Flo

    Hello

    Adding a normal table rule and also a subset rule would not work because the rule would be evaluated only once in the set of positive rules. If the normal rule is evaluated first, then the subset rule and the rest of the rules would not be assessed at all that's why it would not work.

    This can be done using one of the following methods:

    Method 1:

    1 use the declarative transformation on the capture/apply and rename SCH_1 to SCH_2 scheme.
    2. now, on the site apply, define a DML for SCH_2.TAB_1 Manager
    3 al ' DML Handler, do the following:
         
    a. get the value of the STATUS column
    b. check if the value of STATUS = 1, if yes, then change the name of the object to TAB_1_SHORT and run the LCR.
    (c) another thing not to change the name of the object (leave it as it is, TAB_1) and run the LCR.
              
    Method 2:

    1. Add a DML for SCH_1.TAB_1 Manager
    2. in the DML handler perform:
         
    method of set_object_owner use of LCR$ _ROW_RECORD to rename the owner at the SCH_2
    b. get the value of the STATUS column
    c. check if the value of STATUS = 1, if yes, then change the name of the object to TAB_1_SHORT and run the LCR.
    (d) another thing not to change the name of the object (leave it as it is, TAB_1) and run the LCR.

    Please let me know if you need examples of code.

    Thank you
    Florent

  • 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

  • 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 AM

    Yes 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.
    
  • creating views in a new scheme to access some rows of the tables in the source schema

    Hello

    Oracle 10.2.0.4

    We try to hide some data from some users. My suggestion is that we create a new view_schema scheme on the same instance where we said the source tables in source_schema.

    We then create views in view_schema as below

    CREATE VIEW AS SELECT * FROM source_schema.table where COLUMN_n = "XYZ";

    We then grant SELECT on these views to a role and assign this role new users to be able to consult the data consulted.

    If the questions below.

    1. We can create views to view the data in another schema WITHOUT giving SELECT permissions on source_schema.tanle directluy?
    2. It works and there is no need to create synonyms etc.
    3. YOU can manage users and much easilier view (s)

    Is there a sense and who better than the selection seen with say table_name_view in the source schema to this effect and even the creation of synonyms for these points of view with the same name, yasmina in sourece_schema?

    Thank you

    905989 wrote:

    Hello

    Oracle 10.2.0.4

    We try to hide some data from some users. My suggestion is that we create a new view_schema scheme on the same instance where we said the source tables in source_schema.

    We then create views in view_schema as below

    CREATE VIEW AS SELECT * FROM source_schema.table where COLUMN_n = "XYZ";

    We then grant SELECT on these views to a role and assign this role new users to be able to consult the data consulted.

    If the questions below.

    1. We can create views to view the data in another schema WITHOUT giving SELECT permissions on source_schema.tanle directluy?
    2. It works and there is no need to create synonyms etc.
    3. YOU can manage users and much easilier view (s)

    Is there a sense and who better than the selection seen with say table_name_view in the source schema to this effect and even the creation of synonyms for these points of view with the same name, yasmina in sourece_schema?

    Thank you

    1. you can create the view in another schema (first granting of privileges to the schema of the view) without granting privileges of the schema of the source

    2. you probably want to create public synonyms for the view (s).  You can refer to the view as schema.view, but it's bulky

    3. I'm not sure management is easy, but the extra complexity shouldn't be too bad.  Write the documentation describing how everything works and the object involved.

    Another, more complicated, but more powerful option is to use row-level security also known as the virtual private database - if you have the license.  You create a profile for a table and a procedure to generate the WHERE clause to filter a query against the table and the columns defined in the profile.  Yet once, you need license to do this.

Maybe you are looking for