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

Tags: Database

Similar Questions

  • 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

  • foreign key referencing the table in different schema

    I create a foreign key for the table in the schema A a table to diagram B.

    I do that by grant references (column name) on the name of the table to username;


    is there any drawback/disadvantage in the creation of foreign keys referencing tables in another schema?

    Not as such, no.

    Generally, you want to check a second time when you are in this kind of situation that the two tables really belong in different schemas. It should be relatively rare to find a child table that belongs to a different schema than the parent. Sometimes, but it should be an exception, not the rule.

    Justin

  • Data Pump: export/import tables in different schemas

    Hi all

    I use Oracle 11.2 and I would like to use the data pump to export / import data into the tables between the different schemas. The table already exists in the source and target schemas. Here are the commands that I use:


    Script working export:

    expdp scott/tiger@db12 schema = source include = TABLE:------"IN (\'TB_TEST1 ', \'TB_ABC')\ 'directory = datapump_dir dumpfile = test.dump logfile = test_exp.log

    Script to import all the desks:

    Impdp scott/tiger@db12 remap_schemas = rΘpertoire source: target = datapump_dir dumpfile = test.dump logfile = test_imp.log content = data_only table_exists_action = truncate

    Script error for some tables to import:

    Impdp scott/tiger@db12 remap_schemas = source: target include = TABLE:------"IN (\'TB_TEST1')\' directory = datapump_dir dumpfile = test.dump logfile = test_imp.log content = data_only

    Export is good, I got the folling error when I try to import the table TB_TEST1 only: "ORA-31655: no metadata data_or objectsz selected for employment. The user scott is a DBA role, and it works fine when I try to import all tables being export without the include clause.

    It is possble to import some tables but not all tables in the export file?

    Thanks for the help!

    942572 wrote:

    It's good to import all tables exported through Scott, who do NOT have the clause 'include '.

    I have the error only when I try to import some tables with clause "include".

    Can I import only some table since the export dump file? Thank you!

    you use INCLUDE incorrectly!

    do below yourself

    Impdp help = yes

    INCLUDE

    Include the specific object types.

    For example, INCLUDE TABLE_DATA =.

  • EF - Oracle privileges to select tables in different schemas

    Hi, my scheme has only 'connect' and 'resources' privileges, so when you create an .edmx file I see only the tables associated with this particular scheme, when I connect with the diagram of the SYSTEM, I see many many schemas tables, I then added "select any table" my old scheme, but always the same set of tables , what I want to achieve is to select/change/delete others some tables of specific patterns, what privileges do I have to add to be able to do?

    Thanks in advance

    By default the connection shows only certain patterns. You can get EF to show you several of them in this way:

    In Server Explorer, right-click on the connection and go to 'change the connection '. Then click on the "Filters" tab

    One of the filters is to display schema. You can have multiple values in that, he must add the schemas you want to make sure and save the connection.

  • How to join two tables of different schemas of Oracle by using a subquery

    I'm trying to join two different schemas of Oracle tables using a subquery. I can extract data from each of the tables without problem. However, when I combine select statements it by using a subquery I get Oracle error *'ORA-00936: lack of expression ' *. Given that each SELECT statement runs on its own without error I don't understand what's missing. I'm trying to get the result set is matching the LINE_ID of PDTABLE_12_1 in the schema with the table PDTABLE_201 MAT_DESCRIPTION DD_12809 in the RA_12809 schema.

    The query is as follows:

    SQL = "SELECT [DD_12809]. [PDTABLE_12_1]. LINE_ID OF [DD_12809]. [PDTABLE_12_1] JOIN "_".
    + "(SELECT [RA_12809]. [PDTABLE_201]. MAT_DESCRIPTION "_".
    "FROM [RA_12809]. [PDTABLE_201]) AS FAB "_".
    + 'ON [DD_12809]. [PDTABLE_12_1]. PIPING_MATER_CLASS = FAB. PIPING_MATER_CLASS ".

    The format of the request is copied from a manual of programming SQL.

    I also tried running the query uses a right JOIN on the two tables, but got the same results. Any ideas would be useful. Thank you!

    Published by: user11338343 on October 19, 2009 06:55

    The format for the join of two tables in Oracle feels like any other database:

    SELECT a.col1, a.col2, ..., b.col1, b.col2, ...
    FROM   schema1.table1 a,
           JOIN schema2.table2 b ON a.col = b.col and ...
    WHERE  a.other_col = 'FRED'
    AND    ....;
    

    Do not place bracketed identifiers in Oracle. The account that connects to the database must have select privileges on the two tables.

  • Is it better to create a form for the 25 different forms?

    We have a Telco Application (in the form of 10g) which has about 200 forms that are called from the main menu. Off than 200 forms on * 25 * are forms of type 'upload file' (see below).

    http://www.freeimagehosting.NET/alg6q

    As you can see, it's small size. The feature is:
    *(a.) Select a text file (which includes tabular data) of the client computer.
    When the file is selected, it is also copied to a directory on the DB server machine. The file name displays the full path of the file in the client computer.
    * (b) * when the user press the load button, form calls a stored procedure that is packed. We create an EXTERNAL table mapped to the file in the directory db and read the contents of a temporary table in the comic book.
    * (c) * when the user press the Process button, the temporary table is read and our Telco tables are updated using these data.
    * (d) * you can view the records of error and the correct records discovered during treatment, with the option to view the file . This will display 2 Oracle reports.
    * (e) * you can delete the contents of the temporary table by using the option delete temporary .

    This story goes like this: our application is in the form of 10g. Now, we want to update this application Forms 11 g value. We met one of the problems was the FileUploader bean that we use in the forms above. This does not work in 11g. Solution has been found using WebUtil. Now, we must change all the 25 forms (obviously).


    Now here's the really important part: our managers feel that in the future also we may have to move to these 25 forms (due to problems/upgrades future with WebUtil and so on) and they want us to create a form for 25 forms. For example, in a form.

    (a.) we have a list box at the top where chooses to uses which upload function he wants.
    (b.), the file is selected (and then transferred to the DB directory).
    (c.) now when users click on the load button to execute the charge process packed for the selected workload file option.
    (d) when he pressed the Process button we need to run the program for the selected file download function unit.
    (e) when the user presses the button view the file, it should display the correct records and invalid records (found after treatment) 2 speed. The reports differ from a function to a function.
    (f) it can delete the records in the temporary table by using the Delete Temp button.

    Is it good idea? My first study tells me that it isn't a good idea since we have a form with too many features. What are the advantages and disadvantages of this approach and what is the best solution?

    Published by: user12240205 on June 25, 2012 01:16

    The code is not DUPLICATED. The code to load and process is completely different from form to form.

    Looks like the old method of copy-paste-adapt.
    But it surely is something all forms have in common, no? Even if the code is not duplicated the process is (select the file, download it, treat it, call a report, delete temporary data). Look at what needs to be done in general, create an API on that and let your forms to use this API. Ways to form stuff can be done via the user triggers, procedures referenced/copied, etc.. If I were you I would go back, look at the code and see how I can do an API.

    see you soon

  • DataPump - expdp.open creates tables in the schema

    Hello

    I use datapump in Oracle 10 g to archive old main schema to another schema partitions.

    I noticed that when dbms_datapump.open is called and a new table is created by dbms_datadpump for internal purposes. This is verified in the oracle documentation

    http://docs.Oracle.com/CD/B12037_01/AppDev.101/b10802/d_datpmp.htm#997383

    Notes on use

    • When the task is created, a master table is created for work under the scheme of the appellant in the default tablespace of the appellant. A handful referring to employment is returned that attaches to the current session to use. Once attached, the handle remains valid until that either explicit or implicit detach occurs. The handle is only valid in the session of the appellant. Other handles can be attached to the same task from another session using the ATTACH procedure.

    Does anyone know if this table can be removed by a call to dbms_datapump Oracle 'clean', or if it has to be cleaned manually.

    can confirm that this is what you do

    v_job_handle: = DBMS_DATAPUMP. OPEN('EXPORT', 'TABLE', NULL, v_job_name);

    -The parallelism 1 value and add the file

    DBMS_DATAPUMP. SET_PARALLEL (v_job_handle, 1);

    DBMS_DATAPUMP. ADD_FILE(v_job_handle, v_job_name |) '_' || v_partition. PARTITION_NAME | ".dmp", "PARTITION_DUMPS");

    -Apply filters to process only a partition in the table

    DBMS_DATAPUMP. METADATA_FILTER(v_job_handle, 'SCHEMA_EXPR', 'IN ("SIS_MAIN")');

    DBMS_DATAPUMP. METADATA_FILTER(v_job_handle, 'NAME_EXPR', ' AS "' | t_archive_list (i) |) '''');

    DBMS_DATAPUMP. DATA_FILTER(v_job_handle, 'PARTITION_EXPR', ' IN ("' | v_partition.partition_name |)) ')', t_archive_list (i), "SIS_MAIN");

    -Use statistics (rather than blocks) to estimate the time.

    DBMS_DATAPUMP. SET_PARAMETER(v_job_handle, 'ESTIMATE', 'STATISTICS');

    -Start the work. An exception is returned if something is not installed correctly.

    DBMS_DATAPUMP. START_JOB(v_job_handle);

    -The export job should work now. We loop until its finished

    v_percent: = 0;

    v_job_state: = "UNDEFINED";

    WHILE (v_job_state! = 'DONE') and (v_job_state! = "STOPPED") LOOP

    DBMS_DATAPUMP.get_Status (v_job_handle,DBMS_DATAPUMP.ku$_status_job_error + DBMS_DATAPUMP.ku$_status_job_status + DBMS_DATAPUMP.ku$_status_wip,-1, v_job_state, m);

    js: = sts.job_status;

    -As percentage-complete in this loop changes, displays the new value.

    IF js.percent_done! = v_percent THEN

    v_percent: = js.percent_done;

    END IF;

    END LOOP;

    -Once the work is finished, view the status before you loose work.

    PRC_LOG (f1, t_archive_list (i) |) ': Export complete with status: '. v_job_state);

    -DBMS_DATAPUMP. Detach (v_job_handle);

    -Use STOP_JOB instead of DETACHING otherwise 'master' table that is created when the OPEN is called is not removed.

    DBMS_DATAPUMP. STOP_JOB(v_job_handle, 0, 0);

  • Code and the database tables in different schemas

    Hello
    My version of db: database Oracle 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    I would like to understand the advantages and disadvantages of the following situation:
    We have only one request.
    The design of the db for this application has 44 paintings, of which 28 are base tables related by PK and FK relations. The other 16 are look upward and refer to tables that are not related to one.
    The team has decided to place the tables in a diagram 28 A and the other 16 in another schema B within the same database. (The reason for this is... because it's done in other projects to do it here too).
    Coming now to the code (stored procedures, functions, packages, etc.). Teams want to ask most of the code in the diagram B with the Ref 16 tables. (the reason being again the same).
    What are the advantages and disadvantages this?
    Please advice.

    PS:
    I have googled and find something on these lines:
    cons:  
    o harder to manage
    o harder to upgrade
    o harder to patch
    o harder to maintain
    o causes your shared pool size to increase 1,000 times (shared sql goes down the tubes)
    o takes more space
    o queries against the dictionary will be impacted
    o latching on the shared pool goes WAY up (latching = locks = serialization device = 
    slows you down)
    
    pros:
    o none that I can think of.

    From my experience, if you see natural divisions that give you smaller patterns, well contained, you should take advantage of them and start with separate schemas. If done correctly, it can greatly improve the maintainability of your application.

    Assume that your initial project will have 60 paintings and they might fall into three groups of 15, 20 and 25 tables respectively. There are also objects of code such as PL/SQL packages. Your choice is:
    -Use a single scheme of 60 paintings, suppose that with 100 objects in code.
    -Use 3 diagrams divided as described. The total code objects will probably be a little more that unique schema design, because they need to provide interfaces with others. So let's assume that schemas will have 30, 40 and 50 code objects each.

    Now, wait 3 years.

    The history of single-schema:
    -The single-schema is passed to 120 tables. There has been a corresponding increase in code, now more than 200 objects. But they are very complex. Over time, each piece of code will interact with the tables more and more and many other objects in code.
    -You (the architect or Manager) can not really apply any internal for this structure since no subsidy is required to add dependencies. Therefore, if you change a table there is a vast impact.
    -You can easily divide the responsibilities because everything affects everything else. You can't manage simultaneous development efforts because the impact widespread changes cause the same tables/components to be affected by multiple projects. If you have the project execution dependencies / as you have interdependencies technique/code.
    -You have a "big ball of mud" and it is very difficult to get out of this situation.

    Multi-schema history:
    -Each of the 3 original patterns has grown, but some more than others. A fourth was added a year ago, when there was a major expansion in a new district, as a result of "natural divisions.
    -On the inside of each of these schemas, it is always a challenge to impose internal structure. But those patterns more smaller and therefore more small problems.
    -Through schemes, subsidies are necessary to allow interaction, this is not a "wild west" where everyone can access everything (and introduce dependencies on everything). Teams to define interfaces (packages or the views that are specifically intended to be interface points) where the interactions with other scehmas are necessary.
    -If changes to a table are needed, the impact can be limited to the schema that contains naturally. You know that no one else has created dependencies at this table, because you were never issued grants on this.
    -The responsibility for these schemas was divided between 2 teams, each team having full responsibility for its 2 diagrams.
    -Teams can complete projects much more easily, even with a parallel development, because there is less than a "domino effect" with each change.

    Now, these benefits depend on "natural divisions that give you the diagrams smaller, well contained." If you make the wrong choice here, you will always have a mess. You design with the end in mind scenario.

  • Replication of tables in different schemas

    Hello

    I have 2 schemas and would like to have tables (same structure), in 2 different patterns, to be in harmony.

    For example:

    sample1.table_one

    sample2.table_one


    sample1.table_one DESC is exactly the same as sample2.table_one


    I want to both sample1.table_one and sample2.table_one to be in harmony, when changes are made to one of them.

    Oracle 9i does provide a mechanism for this or is the obvious solution only with PL/SQL and triggers.

    Discover the waterways

  • I can't use Lightroom library after updating Windows 10, I can also create a new. Advise me please, (an unexpected error when opening the library)

    Can someone tell me how to create a new library. The one I have is corrupted and I have no idea how to do to create a new library. It does not show in the list. Thank you

    An idea that MAY work to install or run some programs in Windows old 10

    -http://www.tenforums.com/tutorials/15523-compatibility-mode-settings-apps-change-windows-1 0 - a.html

  • Create a schema of the user with the same name and tables within this scheme

    I am a newbie with Oracle.
    I installed my first Oracle 10 g database in my life.
    I need to create a user and a new schema with the same name.
    Subsequently, I need to create tables in this schema using the * isqlPlus.
    I got to create the user via the Oracle Enterprise Manager Console.
    I tried to create a schema through the same tool, but I have not found a possibility to do using GUI.
    Is it possible to do so through Oracle Enterprise Manager Console?
    What are the permissions the user must have access isqlPlus to create the tables in the schema?

    Thank you!!!

    Felipe

    A schema is just a collection of objects belonged to a particular user. If you do not need to create a separate schema: the schema is created automatically when you create the user.

    To connect to the database, a user must CREATE SESSION privilege. To create a table, the user has the CREATE TABLE privilege and should be given a quota on any tablespace will be created in the table. If you don't care management quota or limit the storage space that a user can create tables, you can grant the user the UNLIMITED TABLESPACE privilege. If you care the management of quota, you must run commands like

    ALTER USER <>
      QUOTA <>
      ON <>
    

    for each tablespace for the user to be able to use.

    Justin

  • ORA-00604 with ORA-20010: the user is not authorized to CREATE Table

    Hello

    I use 11.1.0.7 database

    I'm only running this SQL logged on as a schema PLAN. PLAN scheme a DBA privilege but I receive error message-
    create table SALARY.test (ID NUMBER);
    create table SALARY.test (ID NUMBER)
    *
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-20010: PLAN is not allowed to CREATE this -
    SALARY.TEST
    ORA-06512: at line 15
    What can be the problem here?

    Thank you!

    user608897 wrote:

    I know that we cannot use in a DDL trigger, but how can this be a DDL trigger.

    As sybrand hinted it often allows to read a manual.

    http://download.Oracle.com/docs/CD/E11882_01/server.112/e16508/srvrside.htm#CNCPT118

    >
    Overview of triggers

    A database trigger is a stored program unit compiled, written in PL/SQL or Java, that Oracle Database ("fire") automatically calls whenever one of the following occurs:

    1. DML instructions on a particular table or view, issued by a user
    The DML statements modify data in the schema objects. For example, inserting and removing lines are DML operations.

    * 2. DDL statements issued by a particular user or any user *.
    DDL statements define schema objects. For example, create a table and add a column are DDL operations.

    3. database events
    User login or closing of session, errors and database startup or a stop are events that can call triggers.
    >

    A DDL trigger is one that runs when the DDL is made as in 2 above.

    When you create the table, you run DDL, someone wrote a trigger that runs when you try to create the table, and in this trigger, they raise a user-defined exception ORA-20010: the user is not authorized to CREATE Table to tell you that you are not authorized to create the table.

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

  • SQL-Lite create Table?

    I am wanting to save a string of text in a sql database - lite which is called "message1."  I press save button to call this code in my interlocutor.

    URI myURI = URI.create("file:///SDCard/flash.db");
    DatabaseFactory.open(myURI);
    Statement st = d.createStatement( "CREATE TABLE Restaurant (Experience TEXT)" );
    Dialog.alert("Here1!");
    st.prepare();
    st.execute();
    st.close();  
    
    Statement st1 = d.createStatement("INSERT INTO Restaurant(Experience) VALUES ('message1')");
    st1.prepare();
    st1.execute();
    st1.close();
    d.close();
    Dialog.alert("Your info was saved!");
    

    I can't even my Dialog statement to appear?  I do something wrong in the line where I create the table?

    Statement st = d.createStatement ('CREATE TABLE Restaurant (experience TEXT)');

    Because when I move the dialog statement before this line... I can see the dialog box

    Database db;
    URI myURI = URI.create("file:///SDCard/flash.db");
    db = DatabaseFactory.open(myURI);
    
    Statement st= db.createStatement("CREATE TABLE 'Restaurant' ( "
                        + "'Experience' TEXT)");
                st.prepare();
                st.execute();
                st.close();
    
                Statement st1 = db.createStatement("INSERT INTO Restaurant(Experience) VALUES ('Message1')");
                st1.prepare();
                st1.execute();
    
    db.close();
    

    I checked the code and its working very well.

    ----------------------------------------------------------
    feel free to press the congratulations on the left side to thank the user who has helped you.
    Please mark as resolved messages if you found a solution.

Maybe you are looking for