Create table from user scott

Hi,
Can you help me with this?
I wrote this
{declare
cursor c1 is
select *
from
all_objects
where lower(owner) like 'scott'
and lower(object_type)='table';
i varchar2(50);
begin
for i in c1
loop
execute immediate 'create table '||i.object_name|| ' as select *
from ' ||i.object_name;
end loop;
close c1;
end;
and I have the following errors:
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at line 12
Thank you

Could you please show output of your generated code using dbms_output.put_line command?
declare
cursor c1 is
select *
from
all_objects
where lower(owner) like 'scott'
and lower(object_type)='table';
i varchar2(50);
begin
for i in c1
loop
dbms_output.put_line('create table '||i.object_name|| ' as select *
from ' ||i.object_name);
end loop;
close c1;
end;
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com

Similar Messages

  • Labview database problem: Create a database table from user defined fields

    I am trying to create a new table in an access database opened by an ODBC connection from information entered a table stored in the database, but every time I try to create the table, the Labview Database connectivity toolkit VI for creating a table throws a cryptic error
    "Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [Microsoft][ODBC Microsoft Access Driver] Syntax error in field definition. in NI_Database_API.lvlib:Conn Execute.vi->NI_Database_API.lvlibB Tools Create Table.vi->DatabaseCreateHeaders.vi"
    I think this is becuase I am trying to re-create the database  column variable type, but I am not sure what I am doing wrong.  Everything seems to be fine as the data types go, and everything works as long as I use a constant to create the database columns.  I even tried putting all of the information into the format labview defined, changed that to a variant, and redefined it as the labview database column type. 
    I have attached a simplified VI and a picture of what I am trying to
    do, but I would appreciate any help I can get.  Hopefully I won't have
    pulled out all of my hair by the time some one replies!
    Solved!
    Go to Solution.
    Attachments:
    DatabaseUserDefinedTable.vi ‏14 KB
    UserDefinedColumns.JPG ‏48 KB

    Hi everyone. I am new to the database tool kit using labview. I am using labview 9.0f2 on Windows Xp. I am required to create a database (task is to create a table and to insert values into the table using Microsoft access 2007). I am trying to learn using the Create Database table.vi found with the software. I understand that need to create an access file and also had a mdl file which is name after it.(I had created them). Looking at the example given, I would like to add a few more variables, to be exact 6 more variables(therefore i would have 6 colum in my access file rite?). From the "connection information" the help information shows that it contain an 1D array of DB tools colum. ctl and also a cluster of 4 elements. the link to the access file, LabVIEW.udl shows that it restrict the colum in the access file.eg it has only stringcol,intcol,doublecol. I need to add more colum but cant add just like tt.
    qn1: How to i add insert more varibles into the database so that it will apprears in access.
    qn2: I cant drag and insert the "connection information" just to have more input. how do i do it?
    qn3: where can i edit the info so that i can add more cluster into the access? when i drag out the input turn greyish.

  • How to see DDL script(create table) from view

    i want to view create table script(DDL command)
    can u suggest me any view for that.

    Hi
    There's no view where the DDL statement is directly available. It must be reconstructed from many views...
    If you use 9i the simpler way to do that is with DBMS_METADATA. Below and example....
    SQL> SET LONG 1000000
    SQL> SELECT dbms_metadata.get_ddl('TABLE','EMP') FROM dual;
    DBMS_METADATA.GET_DDL('TABLE','EMP')
    CREATE TABLE "SCOTT"."EMP"
    ( "EMPNO" NUMBER(4,0) NOT NULL ENABLE,
    "ENAME" VARCHAR2(10),
    "JOB" VARCHAR2(9),
    "MGR" NUMBER(4,0),
    "HIREDATE" DATE,
    "SAL" NUMBER(7,2),
    "COMM" NUMBER(7,2),
    "DEPTNO" NUMBER(2,0),
    CONSTRAINT "EMP_PK" PRIMARY KEY ("EMPNO")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS" ENABLE,
    CONSTRAINT "EMP_DEPT_FK" FOREIGN KEY ("DEPTNO")
    REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
    ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS"
    Chris

  • How to hide a record in table from users of different sessions ?

    Hi,
    I am having a table say 'EMPLOYEE' with 10 records in it and users X and Y.
    X fetched a row from his session, assume 5th record for perfoming update operation .
    Until X commits his transaction , this 5th record should not viewable to user Y evenwith
    "SELECT * FROM EMPLOYEE" statement .
    How it is possible with oracle ?
    Thanx in advance.
    Regards,
    Hariharan ST

    Look at this example please
    SQL> create user test1 identified by test1;
    User created.
    SQL> grant dba to test1;
    Grant succeeded.
    SQL> conn test1/test1
    Connected.
    SQL> create table test1_id (id number);
    Table created.
    SQL> begin
      2  for i in 1..5 loop
      3  insert into test1_id values(i);
      4  end loop;
      5  commit;
      6  end;
      7  /
    PL/SQL procedure successfully completed.
    SQL> select * from test1_id;
            ID
             1
             2
             3
             4
             5
    SQL> disc
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.5.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> conn / as sysdba
    Connected.
    SQL> create user x identified by x;
    User created.
    SQL> grant dba to x;
    Grant succeeded.
    SQL> create user y identified by y;
    User created.
    SQL> grant dba to y;
    Grant succeeded.
    SQL> conn x/x
    Connected.
    SQL> update test1.test1_id set id=1;
    5 rows updated.
    SQL>
    And now connected by X user, from another session I'm connecting with Y user and issue:
    SQL> conn y/y
    Connected.
    SQL> select * from test1.test1_id;
            ID
             1
             2
             3
             4
             5
    SQL>- - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com

  • Create table from DBMS_SHARED_POOL.SIZES output

    How can I create a table from the output of DBMS_SHARED_POOL.SIZES output ... If possible at all?
    Thank you !

    Your conclusion is just wrong. dbms_shared_pool.keep is geared at procedures and functions which you are calling over and over again, and which you can't afford to be reloaded often.
    The only thing you avoid by pinning a procedure is the overhead of reloading.
    Secondly in both cases you perform 10000000 inserts instead of 1 bulk insert and this is taking time.
    What you should do is
    SQL> l
    1 insert into scott.test
    2 select trunc(dbms_random.value(10,40)), trunc(dbms_random.value(10,40))
    3 from dual
    4* connect by level <= 1000000
    I can insert 1 million rows in 14.51 seconds
    Your method is the slowest possible.
    And yes, you always should use a spfile, but this has nothing to do with the problem at hand.
    Sybrand Bakker
    Senior Oracle DBA

  • Getting error while creating table from one database to other.

    Hi,
    We are getting below error while creating the table from one database to other.
    SQL> create table fnd_lobs parallel compress as select * from [email protected];
    create table fnd_lobs parallel compress as select * from [email protected]
    ERROR at line 1:
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    Regards,
    Bhatia

    hi
    what are the apps version local and remote database???
    Snapshot too old errors occur because Oracle can 't reconstruct a consistent
    image of a block for the purposes of a consistent read.
    I feel at remote database, you are using UNDO, it will be rather easy to iincrease the undo retention time or increase the undo tablespace size.. if you are dealing with roll back segments, you may have rollback segments whose optimal values are too small...
    increase roll back segments size and select again then
    the following metalink notes might be helpful
    ORA-01555 "Snapshot too old" - Detailed Explanation Doc ID: 40689.1
    How To Avoid ORA-01555: Snapshot Too Old When Running PAAPIMP Doc ID: 603259.1
    OERR: ORA 1555 "snapshot too old (rollback segment too small)" Doc ID: 18954.1

  • Create table from external data with dates

    I have a CSV that looks somewhat like this:
    abcuser,12345,5/12/2012,5,250.55
    xyzuser,67890,5/1/2012,1,50
    ghjuser,52523,1/1/1900,0,0
    When I create the external table, then query it I get a date error:
    CREATE TABLE xtern_ipay
    userid VARCHAR2(50),
    acctnbr NUMBER(20, 0),
    datelastused DATE,
    number_rtxns NUMBER(12, 0),
    amtused NUMBER(12, 0)
    organization external ( TYPE oracle_loader DEFAULT directory "XTERN_DATA_DIR"
    ACCESS parameters (
    records delimited BY newline fields terminated BY "," )
    location ('SubscriberStatistics.csv') ) reject limit UNLIMITED;
    Error I see in the reject log:
    Field Definitions for table XTERN_IPAY
    Record format DELIMITED BY NEWLINE
    Data in file has same endianness as the platform
    Rows with all null fields are accepted
    Fields in Data Source:
    USERID CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    ACCTNBR CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    DATELASTUSED CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    NUMBER_RTXNS CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    AMTUSED CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    error processing column DATELASTUSED in row 1 for datafile g:\externaltables\SubscriberStatistics.csv
    ORA-01858: a non-numeric character was found where a numeric was expected
    error processing column DATELASTUSED in row 2 for datafile g:\externaltables\SubscriberStatistics.csv
    ORA-01858: a non-numeric character was found where a numeric was expected
    error processing column DATELASTUSED in row 3 for datafile g:\externaltables\SubscriberStatistics.csv
    ORA-01858: a non-numeric character was found where a numeric was expected
    Any ideas on this? I know I need to tell oracle the format of the date on the external file, but I can't figure it out.

    Try this:
    CREATE TABLE xtern_ipay
       userid         VARCHAR2 (50)
    , acctnbr        NUMBER (20, 0)
    , datelastused   DATE
    , number_rtxns   NUMBER (12, 0)
    , amtused        NUMBER (12, 2)
    ORGANIZATION EXTERNAL
        ( TYPE oracle_loader DEFAULT DIRECTORY "XTERN_DATA_DIR"
    ACCESS PARAMETERS (
    RECORDS DELIMITED BY NEWLINE FIELDS TERMINATED BY "," MISSING FIELD VALUES ARE NULL
    (   userid
      , acctnbr
      , datelastused DATE 'mm/dd/yyyy'
      , number_rtxns
      , amtused)
    location ('SubscriberStatistics.csv') ) reject LIMIT unlimited;
    select * from xtern_ipay;
    USERID                                                ACCTNBR DATELASTU NUMBER_RTXNS    AMTUSED
    abcuser                                                 12345 12-MAY-12            5     250.55
    xyzuser                                                 67890 01-MAY-12            1         50
    ghjuser                                                 52523 01-JAN-00            0          0
    {code}
    Sorry I had to correct the previous statement again for the date format and for the column amtused that was defined without decimals.
    Regards
    Al
    Edited by: Alberto Faenza on May 31, 2012 6:34 PM
    wrong date format mm/dd/yy instead of dd/mm/yy
    Edited by: Alberto Faenza on May 31, 2012 6:40 PM
    Fixed again the date format and the amtused defined with 2 decimals                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • I can't create table from another table?

    Hi everyone!
    I have a problem that I don't known the reason why?
    I'm using Oracle version 8i and I want to create a table from another table, such as:
         CREATE TABLE a_backup as SELECT * FROM a => It's OK, table a_backup is created.
    But there is only a table that I can't created like that, such as:
         CREATE TABLE b_backup AS SELECT * FROM b;
    When I run over command, SQL Plus is not responding... and clients are can't access to DB or Executing forever
    This is the first time I met this problem.
    Can Anyone help me to resolved it?
    Thanks in advance!

    xi`tin wrote:
    Hi everyone!
    I have a problem that I don't known the reason why?
    I'm using Oracle version 8i and I want to create a table from another table, such as:You realize, of course, that 8i is completely out of support .... Is your OS and hardware just as old as your rdbms software, or is it only the rdbms that your company refuses to upgrade?
         CREATE TABLE a_backup as SELECT * FROM a => It's OK, table a_backup is created.
    But there is only a table that I can't created like that, such as:
         CREATE TABLE b_backup AS SELECT * FROM b;
    When I run over command, SQL Plus is not responding... and clients are can't access to DB or Executing forever
    This is the first time I met this problem.
    Can Anyone help me to resolved it?
    Thanks in advance!

  • Create table from query in Form

    I want to create table in Form 6i, on form I have :sdate , :edate and :dpt Item.
    PROCEDURE TableView IS
    BEGIN
    FORMS_DDL('drop table test');
    declare
    v_com varchar2(4000);
    BEGIN
    V_COM := 'Create table test as
           select * from emp
    where hiredate between :sdate and :edate
    and deptno = :dpt
    FORMS_DDL(V_COM);
    end;When I was tried in TOAD It is showing error
    ORA-01036: illegal variable name/number
    Edited by: Ahmed on Oct 19, 2011 11:11 PM

    you can't use bind variables within forms_ddl. An option would be to not do any ddl at all, and do something like this:
    delete from test;
    insert into test(a,b,c)
    select a,b,c from emp
    where hiredate between :sdate and :edate
    and deptno = :dpt;cheers

  • "Create Table from select Query" Vs "Insert into"

    Hi
    Schenaio:
    My Select Query returns more than 10 million records, these records needs to be inserted into another table.
    Approach 1:
    I created table called TABLE1, and inserted the records using INSERT statement as a batch (batch size is 5000).
    Approach 2:
    I create table like,
    CREATE TABLE TABLE1 AS <SELECT QUERY>
    Here Apporach-1 took almost 40 minutes to complete the insert but Approach-2 took only 6 minutes.
    If anybody knows why it is? And is there any way to improve the performance of Approach-1?.
    Thanks
    Nidhi

    Most "batch" methods execute the same query multiple times. Row filtering is done after the rows are fetched from the source. The process of fetching all the rows could be a FullTableScan.
    Therefore, a FullTableScan is executed for each batch of 5000 rows.
    However, your query and batch definitions may well be different. We haven't seen the query and the execution plan.
    Another point : How are you "filtering" the rows (i.e the second execution inserts rows 5001 to 10000 and does not attempt to reinsert rows 1 to 5000) ?
    What is the overhead imposed by the filter ? (does the third execution have to exclude rows 1 to 10000 and inserts rows 10001 to 15000 and so on)
    Hemant K Chitale

  • Create table from another db

    Basically, I need to create a table from a query that runs against another db on a separate box. Is this possible?
    Thanks

    If you're able to create a database link to the other server you could then use the query(modifying the tables in the from clause to use the dblink) in a create table statement.

  • Create table from another table including constraints

    Hi,
    Is there a way to create a table from another table including constraints.
    CREATE TABLE COPY_EMP
    as
    SELECT *
    FROM EMP
    WHERE 1 =2 ;
    This creates the table, but the constraints are not copied over.
    I was reading about DBMS_REDEFINITION - can that be used for this scenario ?
    Thanks!
    Anand

    >
    I tried that, but the constraint names are posing a problem. And unfortunately our constraints are not named in a standard, so am finding it difficult to replace them.
    Was just wondering if there were any simpler approach to this.
    >
    No - there isn't.
    You will have to use new names for the constraints. That usually means extracting the DDL and manually changing the constraint names.

  • How to create table from method

    Hello -
    Could anyone please tell me how can I create af:table with more than one column from an AppsModule method.
    When I have a 1d array return eg:
    public String[] createTable(){
    String[] str = new String[1];
    return str;
    I can drop it as a table and one column gets created. But how can I get mutiple columns in a table. I want to write a method, which when dropped on jsp page create table with multiple columns.
    I am using ADF 11g.
    Please suggest.
    Regards -
    Rohit

    Hi,
    for this you use an array or array list of objects. The object represent the row content, e.g. Person. The Person class then has setter/getter for each of the properties that you want to show in a column
    Frank

  • How to create table from another in pl/sql

    Hi I need to create a table from another in pl/sql
    How can I do this

    The proper way to do this, is not to do it in PL/SQL. But do it in SQL, something like:
    create table tbl
    as
    select *
      from other_tbl;Doing it in PL/SQL is really slow compared to SQL.
    Yes, if you really want to create a table using PL/SQL then you will need to use DBMS_SQL or EXECUTE IMMEDIATE (Native Dynamic SQL) to do this.

  • Question on Creating Table From Insert statement

    Hi,
    I want to create a table using a DBlink from another database using the create/insert statement. Will it also transfer the constraints or do I have to do it manually afterwards? Thanks.
    Create table T1
    SELECT a,b,c from T2 from DB@dblink;

    As discussed above, the constraints, indexes, triggers are not copied. Only NOT NULL constraints are copied.
    Look at this thread Re: Copying table structure.
    for copying triggers/indexes from source table to destination table.
    Thanks,
    Navaneeth

Maybe you are looking for