Select * in < table_name > in oracle

Hello

I would like to create a table in Oracle really liked the way I do in Sybase
SELECT * INTO mytable FROM t WHERE 1 = 2
go
Thank you

Ashok

Try this (DEC)

CREATE TABLE t AS SELECT * FROM mytable WHERE 1 = 2;

Note that unlike Sybase where you need the option of database "SELECT INTO" enabled for SELECT INTO, wiil above work without problem in Oracle.

As usual to ensure that you have enough free space in the Oracle database. ETG won't create any other DDL statement as constaint of primary key or index as they were on the original table (mytable).

HTH,

Mich

Tags: Database

Similar Questions

  • A selection of walls blocking Oracle

    I have following INTERNALLY partitioned tables and local index by BUREAU_CODE:

    CREATE TABLE fin_mea)
    fin_mea_uid NUMBER NOT NULL,
    fiscal_month_uid NUMBER NOT NULL,
    fiscal_year_uid NUMBER NOT NULL,
    bureau_code VARCHAR2 (3) NOT NULL,
    main_acct_code VARCHAR2 (4).
    sub_acct_code VARCHAR2 (3),
    net_amt NUMBER (23.2))
    PARTITION OF the LINE (fiscal_month_uid)
    INTERVAL (1)
    (PARTITION fmea_initial VALUES LESS THAN (200501));

    CREATE INDEX fin_mea_bureau_idx ON fin_mea (bureau_code CAD) LOCAL;

    When I try to select lines of partition does not exist with a condition that uses indexed column that oracle crashes with an error 'end of pipe ':

    SELECT * fin_mea partition to (201301) where a.bureau_code = "ZZZ".

    The following works even without selected lines:

    Select * from (SELECT * FROM fin_mea partition to (201301)) a clause where a.bureau_code = "ZZZ";

    If I remove index then first request works without a problem:

    SELECT * fin_mea partition to (201301) where a.bureau_code = "ZZZ".

    Is this a bug or I do something wrong?

    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0

    I've narrowed the problem to the syntax of the OP used to create the index.

    According to the manual, the list of columns must come * before * the index properties, but there LOCAL before the columns.

    If I change it, the whole scenario works without error.

    Of course, this does not explain why the server process has crashed in the original scenario.  That should not happen.

    But also note that the original syntax of the OP does NOT create a local partitioned index.

    I wonder if this is really where the bug lies.  That should have been a syntax error.

    SQL > CREATE TABLE fin_mea)

    2 fin_mea_uid NUMBER NOT NULL,

    NUMBER of field2 3 NOT NULL,.

    4 fiscal_month_uid NUMBER NOT NULL,

    Field4 NUMBER 5 NOT NULL,.

    NUMBER 6 sphere5 NOT NULL,

    7 case field6 NUMBER NOT NULL,

    NUMBER 8 field7 NOT NULL,

    9 field8 VARCHAR2 (24) NOT NULL,

    NUMBER of field9 10 NOT NULL,

    11 bureau_code VARCHAR2 (3) NOT NULL,

    12 Champ11 VARCHAR2 (3),

    13 field12 VARCHAR2 (3),

    field13 14 number 4,

    Domaine.14 15 number 4,

    16 field15 VARCHAR2 (1).

    17 field16 VARCHAR2 (4).

    18 publique17 VARCHAR2 (3),

    field18 19 number 4,

    20 publique19 number 4,

    21 field.20 NUMBER (5),

    22 field21 VARCHAR2 (3),

    23 matiere22 VARCHAR2 (2),

    field23 24 number 4,

    25 net_amt NUMBER (23.2))

    26 PARTITION BY RANGE (fiscal_month_uid)

    INTERVAL OF 27 (1)

    28 (PARTITION fmea_initial VALUES LESS THAN (200501))

    PCTFREE 29 10

    30 INITRANS 1

    31 255 MAXTRANS

    NOCACHE 32

    33 MONITORING

    34 NOPARALLEL

    35 LOGGING

    36.

    Table created.

    SQL > CREATE INDEX fin_mea_org_idx ON fin_mea (bureau_code) LOCAL

    2 PCTFREE 10

    3 INITRANS 2

    4 MAXTRANS 255

    5 NOPARALLEL

    6 LOGGING

    7.

    The index is created.

    SQL > SELECT * fin_mea partition to (201301) where a.bureau_code = "ZZZ";  --< doesn't="" error="">

    no selected line

    SQL > select separated from user_indexes where index-name = "FIN_MEA_ORG_IDX";

    NOMINAL

    ---

    YES

    SQL > drop index FIN_MEA_ORG_IDX;

    The index is deleted.

    SQL > CREATE INDEX fin_mea_org_idx ON fin_mea LOCAL.< should="" this="" be="" a="" syntax="">

    2 (bureau_code CSA

    3    )

    4 PCTFREE 10

    5 INITRANS 2

    6 MAXTRANS 255

    7 NOPARALLEL

    8 LOGGING

    9.

    The index is created.

    SQL > select separated from user_indexes where index-name = "FIN_MEA_ORG_IDX";

    NOMINAL

    ---

    NO.

  • Table not found, to: select * from EUL5_documents, using Oracle Developer

    Hello world

    Hope all is well,

    In a previous thread.
    Re: Can I export the query "database" to Excel?

    West of stem has provided the name of the discoverer table which contains the reports:
    EUL5_Documents.

    I went to Oracle Developer just to run a select statement on this table.
    (We use discoverer out of an ODS - data warehouse - like repository)

    So in Oracle developer, I signed in ODS and typed:
    Select * from EUL5_documents

    I typed EUL5_ a drop-down list of tables appear, so I chose EUL5_documents

    I get an error msg when I run the table is not found...

    All advice would be appreciated, tx, sandra

    Hi, Sandra
    You are probably using the SunGard ODS?

    If so, you must open a session as long as the owner of the EUL is not the owner of the ODS. In many cases, this account is ODSDISCO.

    You can tell by logging in to the administration tool. Any account that you use to connect there is one that you can use to query the underlying tables. EUL5_DOCUMENTS is definitely one you want to watch.

    Best wishes
    Michael

  • Select * from &lt; table_name &gt;

    Hi all

    I have a little scenario as if I had a table X, which is an empty array. When I do a select query on the table X, its giving out after 5-10 candy Mint. What will be the reason?

    Thank you
    Mani

    The most plausible explanation:
    http://mwidlake.WordPress.com/2012/04/18/shrinking-tables-to-aid-full-scans/

    How don't know guess:
    HOW to: Validate a query of SQL statement tuning - model showing
    When your query takes too long...

  • How to select the rowid with select * from table_name

    Hello guys I have a slider as follows.
      Cursor c1 IS SELECT * FROM FZRASST;
      
        
      -- Row of type FZRASST row
      fzrasst_row c1%ROWTYPE;
    When I try to reference ID to line like this
    fzrasst_row.rowid;
    get an identifier not valid error? How can I reference the row id without implicitly by selecting rowid? is this possible or should I change my select statement to select all the columns on the table?
    Any help would be greatly appreciated.

    Use:

    Cursor c1 IS SELECT rowid,a.* FROM FZRASST a;
    

    SY.

  • by selecting only the time in oracle forms

    Hi all
    as a picker of oracle forms can I select the time in oracle forms in a text element.
    I want to display the time in this format 10:10:30, and I would also like to insert into the table
    I took the data type of this column as varchar2 (15) if I take date can I insert time or varchar2 is ok.
    my version of oracle forms is 10g.


    Please answer...

    Hi, extreme

    extreme wrote:
    Hi all
    as a picker of oracle forms can I select the time in oracle forms in a text element.
    I want to display the time in this format 10:10:30, and I would also like to insert into the table
    I took the data type of this column as varchar2 (15) if I take date can I insert time or varchar2 is ok.

    Better take column with the data type date. You can insert the date and time in the date field.
    You just change the forms.
    Change the data type Date to Datetime

    to view a single moment, use the format mask.

    Hope this helps

  • Oracle Cloud Service database schema... Apex Cloud_Scheduler &amp; E-mail procedure

    Professional Hello, etc. of users experienced Apex.

    I am currently using the oracle database schema cloud service, which is related to my extension service java saas.

    I have a requirement to send reports to certain accounts of e-mail per day. Hence the need to use the CLOUD_SCHEDULER API, APEX_EMAIL API and a custom "Get_REPORT"... return blob function to convert the sql result set to CSV file to be attached to e-mails.

    1 function GET_REPORT returns the BLOB as the query results set CSV file. Autonomous œuvres

    2. I created the 'SENDEMAIL' procedure that accepts the responsibility of the sender and receivers email address, subject and a BLOB (GET_REPORT) to be attached to the email. And sends APEX_MAIL. PUSH_QUEUE. : This method works stand-alone.

    3. I created the "ScheduleCSVToEMAIL" procedure that accepts the e-mail to, from, cc, tablefiltertext, tablename: this procedure combines 1 and 2 as below...

    SQL_TEXT := 'SELECT * FROM '||TABLE_NAME||' WHERE ' || SQL_FILTER ||'';
    REPORT := GET_REPORT(SQL_TEXT);
         SENDENDVI_MAIL2(TO_ADDR,COMMA_CC, FROM_ADDR, EM_TITLE,EM_TITLE,null,null,REPORT,null);
    

    above works fine when run standalone.

    4. I created CLOUD_SCHEDULER PROGRAMS as below

    BEGIN
      CLOUD_SCHEDULER.CREATE_PROGRAM(
      program_name => 'emailtest1',
      program_action => 'SENDENDVI_MAIL3',
      program_type => 'STORED_PROCEDURE',
      number_of_arguments=>10, enabled =>false
      );
      CLOUD_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
      program_name => 'emailtest1',
      argument_position=>1,
      argument_type=>'VARCHAR2',
      DEFAULT_VALUE=>'[email protected]'
      );
      CLOUD_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
      program_name => 'emailtest1',
      argument_position=>2,
      argument_type=>'VARCHAR2',
      DEFAULT_VALUE=>'[email protected]'
      );
      CLOUD_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
      program_name => 'emailtest1',
      argument_position=>3,
      argument_type=>'VARCHAR2',
      DEFAULT_VALUE=>'[email protected]'
      );
      CLOUD_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
      program_name => 'emailtest1',
      argument_position=>4,
      argument_type=>'VARCHAR2',
      DEFAULT_VALUE=>SYSDATE||'_ENDVI_VH_INSURANCE'
      );
      CLOUD_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
      program_name => 'emailtest1',
      argument_position=>5,
      argument_type=>'VARCHAR2',
      DEFAULT_VALUE=>null
      );
      CLOUD_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
      program_name => 'emailtest1',
      argument_position=>6,
      argument_type=>'VARCHAR2',
      DEFAULT_VALUE=>null
      );
       CLOUD_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
      program_name => 'emailtest1',
      argument_position=>7,
      argument_type=>'VARCHAR2',
      DEFAULT_VALUE=>null
      );
       CLOUD_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
      program_name => 'emailtest1',
      argument_position=>8,
      argument_type=>'VARCHAR2',
      DEFAULT_VALUE=>null
      );
       CLOUD_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
      program_name => 'emailtest1',
      argument_position=>9,
      argument_type=>'VARCHAR2',
      DEFAULT_VALUE=>'G_EMAIL_VH_INSURANCE_INFO'
      );
      CLOUD_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
      program_name => 'emailtest1',
      argument_position=>10,
      argument_type=>'VARCHAR2',
      DEFAULT_VALUE=>null
      );
      
      CLOUD_SCHEDULER.ENABLE('emailtest1');
    END;
    

    and

    BEGIN
      CLOUD_SCHEDULER.CREATE_JOB('emailtestrun1', program_name=>'emailtest1');
      CLOUD_SCHEDULER.SET_JOB_ARGUMENT_VALUE('emailtestrun1',1,'[email protected]');
      CLOUD_SCHEDULER.SET_JOB_ARGUMENT_VALUE('emailtestrun1',2,'[email protected]');
      CLOUD_SCHEDULER.SET_JOB_ARGUMENT_VALUE('emailtestrun1',3,'[email protected]');
      CLOUD_SCHEDULER.SET_JOB_ARGUMENT_VALUE('emailtestrun1',4,SYSTIMESTAMP||'_ENDVI_VH_INSURANCE');
      CLOUD_SCHEDULER.SET_JOB_ARGUMENT_VALUE('emailtestrun1',5,SYSTIMESTAMP||'_ENDVI_VH_INSURANCE');
      CLOUD_SCHEDULER.SET_JOB_ARGUMENT_VALUE('emailtestrun1',6,NULL);
      CLOUD_SCHEDULER.SET_JOB_ARGUMENT_VALUE('emailtestrun1',7,NULL);
      CLOUD_SCHEDULER.SET_JOB_ARGUMENT_VALUE('emailtestrun1',8,NULL);
      CLOUD_SCHEDULER.SET_JOB_ARGUMENT_VALUE('emailtestrun1',9,'G_EMAIL_VH_INSURANCE_INFO');
      CLOUD_SCHEDULER.SET_JOB_ARGUMENT_VALUE('emailtestrun1',10,NULL);
      CLOUD_SCHEDULER.ENABLE('emailtestrun1');
    END;
    

    Above, executed but it obviously it didn't, I asked the table "USER_SCHEDULER_JOB_RUN_DETAILS" and I got the reason of failure below.

    ORA-20001: This procedure must be invoked from within an application session. ORA-06512: at "APEX_040200.WWV_FLOW_MAIL", line 339 ORA-06512: at "APEX_040200.WWV_FLOW_MAIL_API", 
    line 97 ORA-06512: at "F1ZKNWJD2RE1.SENDENDVI_MAIL3",line 56
    
    

    Please help what I do to get my work requirement.

    Note: I already tried to use the Scheduler in the format below, who gave the same result

    BEGIN
      CLOUD_SCHEDULER.create_job (
        job_name        => 'ENDVI_AUT_EM_ROCKET',
        job_type        => 'PLSQL_BLOCK',
        job_action      => 'BEGIN SCHEDULE_CSV_EMAIL(''G_EMAIL_VHROCKETDETAILS'',''[email protected]'',''[email protected]'',''[email protected],[email protected]'',NULL,SYSTIMESTAMP||''_TEST SCHEDULE_CSV_EMAIL'',NULL,NULL,NULL); END;',
        repeat_interval => 'FREQ=MINUTELY; INTERVAL=3;',
        enabled         => TRUE);
    
    
      CLOUD_SCHEDULER.set_attribute (
        name      => 'ENDVI_AUT_EM_VH_INSURANCE',
        attribute => 'max_runs',
        value     => 20);
      CLOUD_SCHEDULER.enable(name => 'ENDVI_AUT_EM_VH_INSURANCE');
    END
    

    Right answer

    Hi oladslw,

    You must perform an additional step before calling the API APEX_MAIL outside an Application Express application. Two ways to achieve this are described in the APEX_MAIL documentation (see first Note) and in the APEX_UTIL documentation. Another way is:

    for c1 in ( select workspace_id
                  from apex_workspace_schemas
                 where workspace_name = sys_context( 'userenv', 'current_schema' )
                   and rownum = 1 ) loop
        apex_util.set_security_group_id( p_security_group_id => c1.workspace_id );
    end loop;
    

    The code above retrieves your workspace_id of the dictionary of the current schema-based APEX of (your), then sets the security context of APEX. After that, you will be able to call APEX_MAIL in a same database session.

    Thank you

    Vlad

  • If I run my query in Oracle, it runs without error, but when I run inside c# gives ORA-00911: invalid character

    I like to run below myQuery in c#, but saw the error. No idea what is the problem? If I'm running myQuery in Oracle, it runs without error. "I put all the +" before starting the myQuery line and "end of the line. but nothing changes.

    myQuery =

    with the CBC as

    (

    Select src.table_name src_table_name, src.column_name src_col_name, src.data_type src_data_type, src.data_length src_data_len, src.data_precision src_data_precision, src.data_scale src_data_scale,

    CBC. Nullable src_nullable, decode (T.Constraint_Type, 'P', 'Primary Key', 'U', 'Unique', ") as src_cons

    all_tab_columns CBC

    left join (select Cc.Column_Name, Uc.Constraint_Type

    of user_cons_columns cc, uc user_constraints

    where Cc.Constraint_Name = Uc.Constraint_Name

    and Cc.Table_Name = Uc.Table_Name) t

    on T.Column_Name = Src.Column_Name

    where table_name = 'INSTRUCTOR' and owner = "ERHAN"

    ),

    As TGT

    (

    Select tgt.table_name tgt_table_name, tgt.column_name tgt_col_name, tgt.data_type tgt_data_type, tgt.data_length tgt_data_len,

    TGT.data_precision tgt_data_precision, tgt.data_scale tgt_data_scale, tgt.nullable tgt_nullable,

    Decode (T.Constraint_Type, 'P', 'Primary Key', 'U', 'Unique', ") as tgt_cons

    from all_tab_columns tgt

    left join (select Cc.Column_Name, Uc.Constraint_Type

    of user_cons_columns cc, uc user_constraints

    where Cc.Constraint_Name = Uc.Constraint_Name

    and Cc.Table_Name = Uc.Table_Name) t

    on T.Column_Name = TGT. Column_Name

    where table_name = 'INSTRUCTOR' and owner = "SARIGUL"

    ),

    col_details as

    (

    Select src.src_table_name, nvl (tgt.tgt_table_name, first_value (tgt_table_name) more (order of nulls last tgt_table_name)) tgt_table_name;

    SRC.src_col_name, src.src_data_type, src.src_data_len, src.src_data_precision, src.src_data_scale, src.src_nullable, src_cons,

    TGT.tgt_col_name, tgt.tgt_data_type, tgt.tgt_data_len, tgt.tgt_data_precision, tgt.tgt_data_scale, tgt.tgt_nullable, tgt_cons

    the CBC

    outer join full tgt

    on)

    SRC.src_col_name = tgt.tgt_col_name

    )

    )

    Select *.

    de)

    Select the case sensitive option

    When tgt_data_type! = src_data_type or tgt_data_len! = src_data_len or tgt_data_precision! = src_data_precision or tgt_data_scale! = src_data_scale or tgt_nullable! = src_nullable

    then 'alter table ' | tgt_table_name | 'Edit ' | tgt_col_name | ' ' || src_data_type | ' ' ||

    -case when src_data_type null ('DATE') then

    on the other

    case

    When src_data_type in ('VARCHAR', 'VARCHAR2')

    then ' (' |) NVL (to_char (src_data_len), ' ') | ') '

    otherwise decode (nvl (src_data_precision-1),-1, null, nvl (to_char (src_data_precision), ' ') |) ', ' || NVL (to_char (src_data_scale), ' ') | ')')

    end

    end

    ||

    cases where tgt_nullable = 'Y' then 'null '.

    of another end 'not null '.

    || tgt_cons

    When tgt_col_name is null

    then 'alter table ' | tgt_table_name | 'Add ' | src_col_name | ' ' ||  ' ' || ' ' || src_data_type | ' ' ||

    -case when src_data_type null ('DATE') then

    on the other

    case

    When src_data_type in ('VARCHAR', 'VARCHAR2')

    then ' ('| nvl (to_char (src_data_len), ' ') |) ') '

    otherwise decode (nvl (src_data_precision-1),-1, null, nvl (to_char (src_data_precision), ' ') |) ', ' || NVL (to_char (src_data_scale), ' ') | ')')

    end

    end

    || tgt_cons

    When src_col_name is null

    then 'alter table' | tgt_table_name: ' drop '. tgt_col_name

    end alter_statement

    of col_details

    )

    where alter_statement is not null;

    using (OracleConnection conn1 = new OracleConnection (connectionString))

    {

    conn1. Open();

    Dim myQuery = "";

    using (OracleCommand = new OracleCommand (myQuery, conn1) crtCommand)

    {

    richTextBox1.AppendText (output);

    richTextBox1.AppendText (crtCommand.ExecuteNonQuery (). (ToString());

    richTextBox1.AppendText (output);

    }

    }

    VR;

    myQuery=
    @"with src as
    (
    ...
    ";
    

    That means a @ before the beginning of a string literal mean? -C# Foire - Site Home - MSDN Articles

    as an example

    OracleCommand cmd = con.CreateCommand();
    cmd.CommandText = @"begin apps.mo_global.init('SQLAP'); begin apps.fnd_global.apps_initialize(5710, 20639, 200); end; end;";
    cmd.ExecuteNonQuery();
    

    richTextBox1.AppendText (crtCommand.ExecuteNonQuery (). (ToString());                            

    is this correct? Not sure

    as example try

     using (OracleConnection conn1 = new OracleConnection(connectionString))
    {
        conn1.Open();
    
        string myQuery = "......";                  
    
        using (OracleCommand crtCommand = new OracleCommand(myQuery, conn1))
            {
                richTextBox1.AppendText(Environment.NewLine);
                // richTextBox1.AppendText(crtCommand.ExecuteNonQuery().ToString());
    
    OracleDataReader reader = crtCommand.ExecuteReader();
    while (reader.Read())
      {
        richTextBox1.AppendText(reader.GetString(0));
        // may be also
        // richTextBox1.AppendText(Environment.NewLine);
      }
    
                richTextBox1.AppendText(Environment.NewLine);
    
            reader.Dispose();
            cmd.Dispose();
            }
    
        con.Dispose();
    }
    
  • Release 9.2.0.1.0 Oracle and ALL_TAB_STATISTICS

    Hi all
    I have a simple question.
    I'm working on a version 9.2.0.1.0 and get some info "fight a bunch of tables.
    Until now, I used this:

    -----
    Select atc.table_name, atc.column_name, decode (round (atc.density), 0, "Alta", "Bassa") density, ats.COMMENTS of the atc, ats ALL_TAB_COMMENTS ALL_TAB_COLUMNS where atc.table_name = ats.table_name and atc.table_name as above ('% & table %');)
    -----

    I can't access ALL_TAB_STATISTICS.
    So my question is, is this ALL_TAB_STATISTICS in this version?

    Thank you and have a nice day

    Luca

    The DICT perspective needs to be able to say that. (or obj$ if you really want to go that deep).

    -----------
    Sybrand Bakker
    Senior Oracle DBA

  • Oracle partitioning range Partitioning

    Aloha!

    Our scheme has existing partition. I shared the larger partition with the script below:

    ALTER table table_name
    Split partition PART_NAME to ('YYYYMMDD')
    into (partition PART_NAME1, partition PART_NAME);

    When I check the partition has said after the execution of the separation, I was invited...

    * SQL > select "| p.table_name |': ' | p.PARTITION_NAME: ", p.num_rows of all_tab_partitions p where p.table_name = 'TABLE_NAME' - order by p.table_name; *

    *''|| P.TABLE_NAME |': ' | P.PARTITION_NAME | " NUM_ROWS *.
    ------------------------------------------------------------- ----------
    TABLE_NAME:Q3_                                                            0
    TABLE_NAME:Q4_                                                            0
    TABLE_NAME:PART_NAME1 0
    TABLE_NAME:PART_NAME 0

    The initial state of the partition has been...

    * SQL > select "| p.table_name |': ' | p.PARTITION_NAME: ", p.num_rows of all_tab_partitions p where p.table_name = 'TABLE_NAME' - order by p.table_name; *

    *''|| P.TABLE_NAME |': ' | P.PARTITION_NAME | " NUM_ROWS *.
    ------------------------------------------------------------- ----------
    TABLE_NAME:Q3_                                                    0
    TABLE_NAME:Q4_                                                    0
    TABLE_NAME:PART_NAME 14000000

    My question is, why there is no record of the new partition to split it took an another 24 hours after I got this result?

    SQL > select "| p.table_name |': ' | p.PARTITION_NAME |", all_tab_partitions p.num_rows p where p.table_name = 'TABLE_NAME' order of p.table_name *.

    *''|| P.TABLE_NAME |': ' | P.PARTITION_NAME | " NUM_ROWS *.
    ------------------------------------------------------------- ----------
    TABLE_NAME:Q3_                                                    0
    TABLE_NAME:Q4_                                                    0
    TABLE_NAME:PART_NAME1 555338
    TABLE_NAME:PART_NAME 862207

    Database: Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    Thank you in advance.

    Kind regards
    Hades

    Num_rows (as well as a variety of other columns data dictionary) is fulfilled when collect you statistics on the partition. You really should have gathered fresh statistics after splitting the partition. Presumably, either the default background work or work that you (or your DBA) has race calculated the statistics on the table during your window at night.

    Justin

  • SQL statement to select the tables that are updated today...

    Hi guys,.

    I need to find the names of all the tables that contain rows that are inserted/updated on a given time stamp...

    Below the statement gives me the list of all tables in the database...
    select t.table_name from all_tables t;
    All these tables in the database have a rowversion column which gives the date of update/insertion of a record. I need to write a select statement (probably dynamic) that will give me the names of the tables that contain the rowversion value 24/01/2013...


    Any help is appreciated...

    Napster says:
    Hi kitsoukou,

    Thanks for your reply...

    But when I run your select statement I get an error indicating that the table SYS. DBMS_XMLGEN does not exist.

    Probably something wrong in my environment?

    If I'm not mistaken there are DBMS_XMLGEN 9i.

    The source code is available under

    karthick% ls -lrt $ORACLE_HOME/rdbms/admin/dbmsxml.sql
    -rw-r--r--   1 oracle   dba         7977 Mar 23  2004 /home/oracle/product/10.2.0.5/rdbms/admin/dbmsxml.sql
    

    You can take this and run to install DBMS_XMLGEN.

  • Oracle range Partition maintenance information

    Hello
    I would like to know the range between oldest partition and the new partition on a table. an organization can help me with this?
    I have a query that gives me all the partition tables in the database, now I would like to get the date of the oldest partition and the new partition to get the retention period... any help would be appreciated...

    Here's what I get all the partition tables
    SELECT table_owner, table_name, max (partition_name)
    FROM dba_tab_partitions p
    WHERE p.table_name IN
    select (separate c.TABLE_NAME
    dba_part_key_columns p, dba_tab_cols c
    where p.name = c.TABLE_NAME
    and p.column_name = c.COLUMN_NAME
    and p.object_type = 'TABLE '.
    and c.DATA_TYPE = 'DATE '.
    and p.owner NOT IN ("SYS", "SYSTEM"))
    and p.table_name not like '% BIN ".
    Group of table_owner, table_name
    order of table_owner;

    What is your version of Oracle 4-digit?

    Provide an example of a table and what you consider to be "older" and "newer" partitions Are you talking about tables that are partitioned? INTERVAL of partitioned? What about the subpartitions?

    Why your query uses MAX (partition_name)? How is that useful information - partitions may have all the names including system generated ones.

    And why the oldest and newest you would give the retention period?

    For simple RANGE partitioned tables the info of the range is in the column HIGH_VALUE (a LONG - so need to use PL/SQL) from DBA_TAB_PARTITIONS.

    Suggests that you first train a step by step manual process to do what you want to do and then work on automating it.
    Show me an example of your manual process.

  • How to modify a statement "select into" how to use a cursor

    The following code fails with an exception too many lines. How can I modify statement Select Into the procedure to use a cursor?
    CREATE OR REPLACE PROCEDURE Track_Asset(
       business_date IN NUMBER DEFAULT NULL,
       missing_table_name  OUT VARCHAR2) 
    IS
       ln_business_date NUMBER;
        incorrectdateformat EXCEPTION;
    BEGIN
       IF business_date < 0 
       THEN
          RAISE incorrectdateformat;
       ELSE
          DECLARE
            ln_business_date NUMBER;
          BEGIN
             SELECT MAX(business_date) 
             INTO ln_business_date
             FROM sproof ;
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
             dbms_output.put_line('NO MATCH FOUND'); 
            WHEN OTHERS THEN
            dbms_output.put_line('ORACLE ERROR :' || SQLERRM);        
          END;
          
          DECLARE
            missedfeedfnd EXCEPTION;
          BEGIN
             SELECT 'Missing Value : ' || table_name 
             INTO missing_table_name 
             FROM ( 
                SELECT UPPER(table_name) table_name 
                FROM filespec
                WHERE data_table_name IN ('TABLE1','TABLE2','TABLE3') 
                MINUS ( 
                SELECT DISTINCT UPPER(first_table_name) 
                FROM dpca
                WHERE business_date = ln_business_date 
                AND first_table_name IN ('TABLE1','TABLE2','TABLE3') 
                GROUP BY UPPER(first_table_name) UNION 
                SELECT UPPER(first_table_name) 
                FROM dpca
                WHERE business_dt_num = TO_NUMBER( SUBSTR('201111', 1, 6) || '01' )
                AND first_table_name = 'TABLE4' 
                GROUP BY UPPER(first_table_name) ));
                
                IF missing_table_name  IS NOT NULL THEN
                   dbms_output.put_line('Missing Value : '|| missing_table_name);
                   RAISE missedfeedfnd;
                ELSE
                  NULL;
                END IF;
          EXCEPTION
             WHEN TOO_MANY_ROWS THEN
       DBMS_OUTPUT.PUT_LINE (' SELECT INTO statement retrieved multiple rows');
              WHEN missedfeedfnd THEN 
              raise_application_error ( - 20003, 'Missed Feed');
          END;
        END IF;
          EXCEPTION
       WHEN incorrectdatevalue 
       THEN
          raise_application_error ( - 20001, 'Incorrect/Bad Date Entered');
    END;

    OK, try this - OUT param will be filled with the table names comma-separated list:

    PROCEDURE Track_Asset(
       business_date IN NUMBER DEFAULT NULL,
       missing_table_name  OUT VARCHAR2)
    ...
    ...
    
    cursor c_table_names is
    select datatablename
    from   ( select upper(datatablename) datatablename
             from   filespec
             where  data_table_name in ('TABLE1','TABLE2','TABLE3'                                 )
            MINUS
            ( select upper(first_table_name)
              from   dpca
              where  business_dt_num = [-- this date is retrieved by getting the MAX(business_date) from sproof table]
                     and fus_data_table_name in ('TABLE1','TABLE2','TABLE3'
                                                )
              group  by
                     upper(first_table_name)
             UNION
              select upper(first_table_name)
              from   dpca
              where  business_dt_num = to_number( substr('201111',1,6) || '01' )
                     and first_table_name = 'TABLE4'
              group  by
                     upper(first_table_name)
            ));
    
    ...
    ...
    begin
       ...
       for rec in c_table_names
       loop
           missing_table_name  := missing_table_name  || rec.datatablename ||',';
       end loop;
       missing_table_name  := rtim(missing_table_name , ',');
    ...
    ...
    end ;
    

    HTH

    Published by: user130038 on December 28, 2011 08:46

  • Examples of Oracle for models

    Hi everyone - I need help in learning Oracle DB
    I am unable to start Lele customerss product tables, sales and costs. I installed Oracle 11 g using the book
    When I run the command: client desc, or one of the tables, I get the error ORA-04043: dept of the object does not exist

    Help is very appreciated!

    900796 wrote:
    I see all the tables, but still do not see who is the owner of each...
    Select the owner of dba_tables;< would="" it="" be="" correct="">
    Correct me

    Select owner, table_name from dba_tables;

    SELECT COUNT (*) FROM TABLE1;
    Failure to Oracle is that the current user is owner of TABLE1 TABLE1 can exist for more than 1 scheme.

    The table belongs to a different schema, proceed as below

    SELECT COUNT (*) IN THE ANOTHER_SCHEMA. TABLE1;

  • Problem with "select * from table" for dynamic IN the list

    I have a 'for loop' based a query that does not work. The query is supposed to return the name of the table, the data type and the name of the column in the columns poses a number of name filters. The problem I have is when I run the query into a TOAD with:

    schema_list value SCOTT, MED and the clause of 'in' as ' to (select * from table (DATAPUMP_UTIL.in_list_varchar2 (:schema_list))))»

    The query returns the expected lines.

    When I have it in my code as shown below it returns no rows. I don't know what hurts me, but any help would be great! I'm on Oracle 11.1.0.6.0.
    PROCEDURE export_schema_ondemand (schema_list VARCHAR2, encrypt_file NUMBER default 0, mask_sensitive_data NUMBER default 0) IS  
        ...
        schema_list_t := my_package.in_list_varchar2(schema_list);
        ... 
        for c1 in
           (
            with ok_to_mask as (
            select 
                owner,
                table_name, 
                column_name
            from   
               all_tab_columns
            where
                owner in (select * from table(schema_list_t))
            minus
            (SELECT 
                c.owner,
                p.table_name,
                cc.column_name
            FROM 
                all_cons_columns cc, 
                all_constraints p,
                all_constraints c
            WHERE 
                c.owner in (select * from table(schema_list_t))
                c.constraint_type = 'R'
                AND p.owner = c.r_owner
                AND p.constraint_name = c.r_constraint_name
                AND cc.owner = c.owner
                AND cc.constraint_name = c.constraint_name
                AND cc.table_name = c.table_name
            UNION ALL
            SELECT 
                c.owner,
                cc.table_name,
                cc.column_name
            FROM 
                all_cons_columns cc,
                all_constraints p,
                all_constraints c
            WHERE
                p.owner in (select * from table(schema_list_t))
                AND p.constraint_type in ('P','U')
                AND c.r_owner = p.owner
                AND c.r_constraint_name = p.constraint_name
                AND c.constraint_type = 'R'
                AND cc.owner = c.owner
                AND cc.constraint_name = c.constraint_name
                AND cc.table_name = c.table_name))
            select 
                atc.table_name as mask_tab, 
                atc.column_name as mask_col, 
                atc.data_type as mask_type
            from   
                all_tab_columns atc,
                ok_to_mask otm
            where
                atc.owner = otm.owner
                and atc.table_name = otm.table_name
                and atc.column_name = otm.column_name
                and atc.owner in (select * from table(schema_list_t))
                and 
                (
                atc.column_name like '%LAST%NAME%'
                or atc.column_name like '%FIRST%NAME%'
                or atc.column_name like '%NAME_LAST%'
                or  atc.column_name like '%NAME_FIRST%'
                or  atc.column_name like '%ENAME%'
                or atc.column_name like '%SSN%'
                or atc.column_name like '%DOB%'
                or atc.column_name like '%BIRTH%'
                )
                and atc.column_name not like '%PHYSICIAN_%'
                and atc.column_name not like '%DR_%'
                and atc.column_name not like '%PROVIDER_%'
                and atc.column_name not like 'PRESCRIBER_%'     
           )
          loop
             ...
    
    FUNCTION in_list_varchar2 (p_in_list  IN  VARCHAR2)  RETURN VARCHAR2_TT is
    
        l_tab   VARCHAR2_TT := VARCHAR2_TT();
        l_text  VARCHAR2(32767) := p_in_list || ',';
        l_idx   NUMBER;
            
    BEGIN
        LOOP l_idx := INSTR(l_text, ',');
            EXIT WHEN NVL(l_idx, 0) = 0;
            l_tab.extend;
            l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
            l_text := SUBSTR(l_text, l_idx + 1);
        END LOOP;
    
        RETURN l_tab;
            
    END in_list_varchar2;
    Published by: BluShadow on June 29, 2011 16:11
    addition of {noformat}
    {noformat} tags.  PLEASE READ {message:id=9360002} TO LEARN TO DO THIS YOURSELF.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

    Hello

    If you have a query that works well when you launch it directly, and that breaks down when you start with a procedure, this can be a problem of privileges.

    Points of view ALL_ * shows only the objects you have access, but using a procedure, privileges must be granted directly to the user and not with a role.

    You should check the SELECT privileges to your user through roles and give them directly to the user.

    Hope this will help.

    Sylvie

Maybe you are looking for