Create table bulk_load as select ename from emp where 1=2

The Above Query will create a new table using the strucure of old but there will be no data..
Kindly explain me what is meant by "where 1=2"?
Is it referring the table or column or for just testing the query??

Is not a rule that you always must use 1=2... look this example:
sql >> create table t as
2 select * from all_objects;
Table created.
sql >> select count(*) from t;
COUNT(*)
43975
sql >> create table ttt as
2 select * from t where rownum=0;
Table created.
sql >> create table tt as
2 select * from t where 9=4;
Table created.

Similar Messages

  • Select  ename from emp where ename like LIKE 's%';

    Hi friends,
    select ename from emp where ename like LIKE 's%';
    output am geting like this naseer
    anusha
    basha
    But I want to display like this naeer    anuha   baha

    784585 wrote:
    Hi friends,
    select ename from emp where ename like LIKE 's%';
    output am geting like this naseer
    anusha
    basha
    But I want to display like this naeer    anuha   baha
    Use REPLACE function:
    SQL>  select replace('naseer','s','') replace from dual;
    REPLACE
    naeerKamran Agayev A.
    Oracle ACE
    My Oracle Video Tutorials - http://kamranagayev.wordpress.com/oracle-video-tutorials/

  • Whats the meaning of plus in query : select employeename from emp where emp

    Hi All,
    Can someone please explain me whats the meaning of plus sign in following SQL. I have nevercome across this syntax
    select employeename from emp where empid(+) >= 1234.

    Example of equivalent queries using oracle syntax and ansi syntax
    SQL> ed
    Wrote file afiedt.buf
      1  select d.deptno, d.dname, e.ename
      2  from dept d, emp e
      3* where d.deptno = e.deptno (+)
    SQL> /
        DEPTNO DNAME          ENAME
            20 RESEARCH       SMITH
            30 SALES          ALLEN
            30 SALES          WARD
            20 RESEARCH       JONES
            30 SALES          MARTIN
            30 SALES          BLAKE
            10 ACCOUNTING     CLARK
            20 RESEARCH       SCOTT
            10 ACCOUNTING     KING
            30 SALES          TURNER
            20 RESEARCH       ADAMS
            30 SALES          JAMES
            20 RESEARCH       FORD
            10 ACCOUNTING     MILLER
            40 OPERATIONS
    15 rows selected.
    SQL> ed
    Wrote file afiedt.buf
      1  select d.deptno, d.dname, e.ename
      2* from dept d left outer join emp e on (d.deptno = e.deptno)
    SQL> /
        DEPTNO DNAME          ENAME
            20 RESEARCH       SMITH
            30 SALES          ALLEN
            30 SALES          WARD
            20 RESEARCH       JONES
            30 SALES          MARTIN
            30 SALES          BLAKE
            10 ACCOUNTING     CLARK
            20 RESEARCH       SCOTT
            10 ACCOUNTING     KING
            30 SALES          TURNER
            20 RESEARCH       ADAMS
            30 SALES          JAMES
            20 RESEARCH       FORD
            10 ACCOUNTING     MILLER
            40 OPERATIONS
    15 rows selected.
    SQL>

  • Select * from emp where ename=(procedure1(procedure2(procedure3)));

    I have a big problem
    I have to check the data for quality data
    Lets say i have to check data in emp table
    First i have to check whether the empno is of type number
         IF empno=number then
              if ename starts with a particualar format then
                   ---printouts and this procedure goes on for about 10 coulumns
    I have designed a hard coded procedure where I input table name and column name and the procedure does the checks and give out result
    I have planned to call that procedures here for each checks
    its like i make the procedure to execute and the procedure returns rowid of the correct data
    now i have to apply the second procedure where input is all the rowids of previous procedure and it goes on
    I even dont know whether procedure is correct or function is correct
    Its like select * from emp where ename=(procedure1(procedure2(procedure3)));
    each procedure's output is Rowids only which satisfy a particular format of data
    Please explain me in details
    Please please help me.

    Nested calls are not the best of ideas. Ignoring that for a moment, there are a couple of ways to address this requirement in Oracle. One of these, and likely one of the more scalable ways, is to use Pipeline Table Functions.
    The following code demonstrates the basics of this approach, using pipelined table functions to perform validation checks on data.
    SQL> -- generic type to serve as input cursors to the validation functions
    SQL> create or replace type TFormatCheckRow as object
      2  (
      3          row_identifier  varchar2(30),
      4          value           varchar2(100)
      5  );
      6  /
    Type created.
    SQL>
    SQL> -- validation functions returns the rowid of rows that are valid
    SQL> create or replace type TRowID as object
      2  (
      3          row_identifier  varchar2(30)
      4  );
      5  /
    Type created.
    SQL>
    SQL> create or replace type TRowIDTable is table of TRowID;
      2  /
    Type created.
    SQL>
    SQL>
    SQL> create or replace package LIB is
      2
      3          type    TCursor is REF CURSOR;
      4  end;
      5  /
    Package created.
    SQL>
    SQL> -- sample validation function to check if the value is a valid NUMBER, and
    SQL> -- if so will return the rowid of that row for further processing
    SQL> create or replace function ValidateNumber( c LIB.TCursor ) return TRowIDTable
      2          pipelined is
      3
      4          MAX_FETCH_SIZE  constant number := 100;
      5          type    TBuffer is table of TFormatCheckRow;
      6
      7          buffer  TBuffer;
      8
      9          function IsNumber( val varchar2 ) return boolean is
    10                  n       number;
    11          begin
    12                  n := TO_NUMBER( val );
    13                  return( TRUE );
    14          exception when OTHERS then
    15                  return( FALSE );
    16          end;
    17
    18  begin
    19          loop
    20                  fetch c bulk collect into buffer limit MAX_FETCH_SIZE;
    21
    22                  for i in 1..buffer.Count
    23                  loop
    24                          if IsNumber( buffer(i).value ) then
    25                                  PIPE ROW( TRowID( buffer(i).row_identifier ) );
    26                          end if;
    27                  end loop;
    28
    29                  exit when c%NOTFOUND;
    30          end loop;
    31
    32          close c;
    33
    34          return;
    35  end;
    36  /
    Function created.
    SQL> show error
    No errors.
    SQL>
    SQL>
    SQL> -- a sample table to check
    SQL> create table foo_tab
      2  (
      3          some_value      varchar2(20)
      4  )
      5  /
    Table created.
    SQL>
    SQL>
    SQL> -- put some data into the table
    SQL> insert
      2  into       foo_tab
      3  select
      4          object_id
      5  from       all_objects
      6  where      rownum < 11
      7  /
    10 rows created.
    SQL>
    SQL> insert
      2  into       foo_tab
      3  select
      4          SUBSTR(object_name,1,20)
      5  from       all_objects
      6  where      rownum < 11
      7  /
    10 rows created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> -- return rowids of all rows from FOO_TAB where the column SOME_VALUE is a valid number
    SQL> select
      2          row_identifier
      3  from       TABLE(ValidateNumber( CURSOR(select TFormatCheckRow(f.rowid,f.some_value) from foo_tab f) ))
      4  /
    ROW_IDENTIFIER
    AAAOQKAAEAAAAFQAAA
    AAAOQKAAEAAAAFQAAB
    AAAOQKAAEAAAAFQAAC
    AAAOQKAAEAAAAFQAAD
    AAAOQKAAEAAAAFQAAE
    AAAOQKAAEAAAAFQAAF
    AAAOQKAAEAAAAFQAAG
    AAAOQKAAEAAAAFQAAH
    AAAOQKAAEAAAAFQAAI
    AAAOQKAAEAAAAFQAAJ
    10 rows selected.
    SQL>
    SQL>
    SQL> -- list the rows that contain valid numbers
    SQL> with ROWID_LIST as
      2  (
      3  select
      4          row_identifier
      5  from       TABLE(ValidateNumber( CURSOR(select TFormatCheckRow(f.rowid,f.some_value) from foo_tab f) ))
      6  )
      7  select
      8          *
      9  from       foo_tab f
    10  where      f.rowid in (select row_identifier from ROWID_LIST)
    11  order by 1
    12  /
    SOME_VALUE
    258
    259
    311
    313
    314
    316
    317
    319
    605
    886
    10 rows selected.
    SQL>

  • Create Table Temp As Select * from Table

    What happens in the backend (performance point of view) when we create a table as follows:
    Create Table Temp As Select * from Table1;
    Suppose that the table Table1 has 10 million rows.
    How is this different from inserting 10 million rows using Insert Statement in a script etc. into Temp table.
    i.e. insert into temp values(1, 'description', sysdate);

    >
    Create Table Temp As Select * from Table1; is always faster than inserting different rows using insert scripts.
    >
    Incorrect - not sure where you got that information.
    The two things being talked about that can affect performance are the use of direct-path loads and whether those loads are logged.
    It makes no difference if the table is created first and then loaded using INSERT or if a CTAS is used to do both.
    A traditional INSERT can use the APPEND hint to perform a direct-path load.
    >
    Cretae table Temp As select * from Tabl1 does not generate logging to the database.Also as datatypes are determined automatically ,there is less work up front.
    >
    The statement that CTAS 'does not generat logging' is incorrect. Whether logging is generated depends on whether the table is in LOGGING or NOLOGGING mode. A CTAS does not automatically, on its own bypass logging.
    To bypass logging and existing table can be set to NOLOGGING mode
    ALTER TABLE myTable NOLOGGINGAnd for CTAS the mode can be specified as part of the statement
    Create table Temp NOLOGGING As select * from Tabl1;

  • Table structure changes when using 'create table X as ( select * from X@remote_server )'

    I need to create and copy data from a remote Oracle server to a local server. The command I use is
    create table X as ( select * from X@remote_server )
    with remote_server is the tns name of the remote Oracle server.
    The local table is created and populated with data as expected but when I check the structure using 'desc X' it shows me all the CHAR fields of the local table are triple as large as of the remote table.
    I guess the problem is the difference  between the NLS_CHARACTERSET settings . The local charset is AL32UTF8 and the remote is  WE8MSWIN1252.
    How do I change the command to make the two tables have the same field sizes ?
    Thanks,
    Vu

    Do you want to be able to store all the data from the remote table in the local table?  Assuming you do, increasing the size of the column would be the correct behavior.
    By default, a VARCHAR2(10) allocates up to 10 bytes of storage.  In the Windows-1252 character set on the source, 1 character requires 1 byte of storage.  So a VARCHAR2(10) has space for up to 10 characters.  In the UTF-8 character set on the destination, however, 1 character can require up to 3 bytes of storage.  So a VARCHAR2(10) may allow you to store as few as 3 characters.  Since Oracle has no way of knowing what data you have (and will have) in the source system, it triples the size to ensure that all the data from the remote system will fit in the new table.  If you want the columns to be the same size on the destination that they are on the source, it is highly probable that you'll get errors inserting the data because at least one value will be too large for the destination column.
    Justin    

  • CREATE TABLE A AS SELECT * FROM B WHERE 1 = 2'-Queries

    Guys,
    I request your guidance in the effect of Create table statement below:
    CREATE TABLE A AS SELECT * FROM B WHERE 1 = 2';
    Question:
    1)What would be the PCTFREE value for table A-Would it inherit PCTFREE from table B?
    2) Will table A be created with LOGGING or NO LOGGING?-Will it iinhert the same from table B?
    3) What would be the degree of parallelism of table A?-Will it inherit the DOP from B?
    Thank you very much for your guidance in advance..
    Regards,
    Bhagat

    1 => it will inherit from the default value
    2 => same thing
    3 => same thing
    The create table as select will only copy the structure of the source table and can copy the datas too. That is all.

  • Select action_type from fnd_conc_pp_actions where action_type=6;

    hi
    SELECT fcpp.concurrent_request_id req_id, fcp.node_name, fcp.logfile_name
    FROM fnd_conc_pp_actions fcpp, fnd_concurrent_processes fcp
    WHERE fcpp.processor_id = fcp.concurrent_process_id
    AND fcpp.action_type = 6
    AND fcpp.concurrent_request_id = &&request_id
    ;its returning logfile name ...
    AND
    select count(*) from fnd_conc_pp_actions where action_type=6;its returning 460 rows.
    i want to know what is action_type?
    and how to know about all attribute about this fnd tables?
    regards

    Helios- Gunes EROL wrote:
    Hi;
    For your question please check e-trm site. You can find relation&explanation&integration and more on e-trm site.(etrm.oracle.com)
    Regard
    Heliosetrm is not opening.

  • 8520 curve rror: Sqlite Error (schema update): net.rim.device.api.database.DatabaseException: SELECT name FROM sqlite_master WHERE type = 'index' AND name = 'chat_history_jid_index': disk I / O error (10).

    Dear team support,
    I have a problem with my WhatsApp Messenger.
    my whatsapp wont save message history. couse error.
    Error: Sqlite Error (schema update):
    net.rim.device.api.database.DatabaseException: SELECT name FROM sqlite_master WHERE type = 'index' AND name = 'chat_history_jid_index': disk I / O error (10).
    Please advise me how can i solve my memory card issue..
    Thanks

    ls -l /var/run/lighttpd/
    And how are you spawning the php instances? I don't see that in the daemons array anywhere.
    EDIT: It looks like the info in that page is no longer using pre-spawned instances, but lighttpd adaptive-spawn. The documentation has been made inconsistent it looks like.
    You will note that with pre-spawned information, the config looks different[1].
    You need to do one or the other, not both (eg. choose adaptive-spawn, or pre-spawn..not both).
    [1]: http://wiki.archlinux.org/index.php?tit … oldid=8051 "change"

  • SELECT OBJECT_NAME FROM DBA_OBJECTS WHERE STATUS = 'INVALID'; = 39 rows .

    We just applied "SAP Bundle Patch 10.2.0.4.5 - 201010" in our development system.
    We completed all the post installation activities.
    In tail end - when we execute subjected command, 39 rows returned.
    Very First --- May we understand  What is the negative impact on Oracle system?
    Secondly -- Do we need to make these rows to "ZERO" is must ?
    Finally -  How to make them to "ZERO"
    2 lines expert advise...will enable us to move forward.
    Rgds
    ==========
    COMMAND
    ==========
    SQL> SELECT OBJECT_NAME FROM DBA_OBJECTS WHERE STATUS = 'INVALID';
    OBJECT_NAME
    LOGMNR_KRVRDLUID3
    DBMS_SQLTCB_INTERNAL
    DBMS_LOGMNR_FFVTOLOGMNRT
    DBMS_LOGMNR_OCTOLOGMNRT
    DBMS_RULE_EXP_UTL
    DBMS_LOGSTDBY
    DBMS_AW_EXP
    DBMS_SNAP_INTERNAL
    DBMSOBJG_DP
    DBMS_REPCAT_EXP
    DBMS_STREAMS_TBS_INT_INVOK
    DBMS_FILE_GROUP_UTL
    DBMS_FILE_GROUP_UTL_INVOK
    DBMS_STREAMS_MT
    DBMS_LOGREP_EXP
    DBMS_LOGREP_IMP
    DBMS_STREAMS_RPC
    DBMS_STREAMS_DATAPUMP
    DBMS_STREAMS_DATAPUMP_UTIL
    DBMS_STREAMS_TBS_INT
    DBMS_STREAMS_TBS_INT_INVOK
    DBMS_STREAMS_TABLESPACE_ADM
    DBMS_FILE_GROUP_UTL
    DBMS_FILE_GROUP_UTL_INVOK
    DBMS_FILE_GROUP
    DBMS_FILE_GROUP_INTERNAL_INVOK
    DBMS_FILE_GROUP_EXP
    DBMS_FILE_GROUP_IMP_INTERNAL
    DBMS_REDEFINITION
    DBMS_CDC_DPUTIL
    LOGMNR_KRVRDREPDICT3
    DBMS_CDC_DPUTIL
    DBMS_CDC_EXPDP
    DBMS_CDC_EXPVDP
    DBMS_CDC_IMPDP
    DBMS_SCHEMA_COPY
    UTL_RECOMP
    DBMS_SQLTUNE_INTERNAL
    DBMS_CDC_DPUTIL
    39 rows selected.
    SQL>
    ==========

    Hi,
    there has been an issue with an earlier set of bugfixes or an older CPU patch.
    It did invalidate the catproc component.
    Check:   select comp_id,status, version from dba_registry;
    if CATPROC is invalid, shutdown and startup your DB.
    run
    @?/rdbms/admin/catproc.sql
    it can run between 10 and 25 minutes depending on horse powers.
    Check again:   select comp_id,status, version from dba_registry;
    CATPROC should now be valid.
    If yes run utlrp.sql again and your errors will be gone.
    If not, your issue is something else.
    Volker

  • About SELECT VALUE FROM NLS_INSTANCE_PARAMETERS WHERE PARAMETER =""

    I am developing a web application based on Oacle 10g .But after the DBServe was startedup for about 5~6 hours, the max connection process exceeded. From the DB Administration Tool it shows that there were many INACTIVE Connections which executed
    SELECT VALUE FROM NLS_INSTANCE_PARAMETERS WHERE PARAMETER ='NLS_DATE_FORMAT'
    But it seems that this is called by the JDBC driver, not my application. How to avoid this, or release the inactive connection?
    By the way,who and when call that sql?
    Thanks a lot.

    By the way,who and when call that sql?Also for this you can take an 10046 level 8 sql trace and format the output with sys=yes option of tkprof - http://tonguc.wordpress.com/2006/12/30/introduction-to-oracle-trace-utulity-and-understanding-the-fundamental-performance-equation/
    Since we are talking about a web application you may use a database logon trigger to start sql trace for your application user, or if possible you may set sql_trace database parameter to true at instance level for a while and since you are at 10g you can use new package dbms_monitor and trcsess utility - http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/sqltrace.htm#sthref2001
    Best regards.

  • Create table script by passing value from table

    I Have a procedure to check if the table exists, if yes drop and re-create else create table.
    CREATE OR REPLACE
    PROCEDURE test_proc authid current_user
    AS
    v_cnt NUMBER:=0;
    BEGIN
    SELECT COUNT(*)
    INTO v_cnt
    FROM all_tables
    WHERE table_name='T1'
    AND owner = 'WORKSPACE';
    IF v_cnt = 1 THEN
    EXECUTE immediate 'DROP TABLE WORKSPACE.T1';
    END IF;
    EXECUTE immediate 'CREATE TABLE WORKSPACE.T1
    ITM_NBR NUMBER ,
    LCT_NBR NUMBER
    SELECT COUNT(*)
    INTO v_cnt
    FROM all_tables
    WHERE table_name='T2'
    AND owner = 'WORKSPACE';
    IF v_cnt = 1 THEN
    EXECUTE immediate 'DROP TABLE WORKSPACE.T2';
    END IF;
    EXECUTE immediate 'CREATE TABLE WORKSPACE.T2
    LCT_NBR NUMBER(5, 0) NOT NULL ,
    PRY_CD NUMBER(5, 0) NOT NULL )';
    END;
    Requirement: Instead of passing the Owner,tablename & the create table scripts directlyin the query, it should be passed from a database table which will be in given format.
    TableName Query Owner
    T1 CREATE TABLE WORKSPACE.T1(ITM_NBR NUMBER, LCT_NBR NUMBER) WORKSPACE
    T2 CREATE TABLE WORKSPACE.T2(LCT_NBR NUMBER(5, 0) NOT NULL ,PRY_CD NUMBER(5, 0) NOT NULL) WORKSPACE

    user12276240 wrote:
    Excuse all. The database columns are yet to be finalized and every time changes come in we are currently dropping and re-creating the tables which leads in changing the script, hence we are going in for this approach.
    Moreover if i am going to have this script everytime i have to drop and re-create all the tables which can be elimated by this way.So why not have a SQL script as follows?
    drop table emp purge;
    create table emp(
    create index .. on emp( .. );
    ..It drops the existing table (if exists). It then creates the table with constraints and indexes. This script is now the master definition of the table. You can slap a change log header to it. Any changes that needs the table to be redefined and recreated are done via this script. Which means it is also checked into the source code repository as it is part of the code of that system/application.
    I would however remove the drop table from it in case some developer accidentally run it at the wrong time and trash the table.
    The bottom line is that DDL code is part and parcel of the installation, configuration and setup code - and that this is as important as the source code. This code also needs to be "formalised" in proper scripts, checked into SVN/CVS/etc, and used to bootstrap the system (or parts of it), as and when needed.

  • ADF - How to create table which column header come from query result

    I would like to create table that show the summary of task for each month, the query result such as
    Status MonthofYear Total Task
    03 2007/06 9
    03 2007/05 12
    03 2007/04 10
    03 2007/03 7
    05 2007/06 6
    05 2007/05 3
    06 2007/06 1
    09 2007/06 1
    And the table that I would like to show in jdeveloper is
    Status 2007/06 | 2007/05 | 2007/04 | 2007/03 | ......... | 2006/05
    03 9 | 12 | 10 | 0 | .......
    05 6 | 3 | 0 | 0 | .......
    06 1 | 0 | 0 | 0 | .......
    09 1 | 0 | 0 | 0 | .......

    Lucas worked out a solution for this:
    http://technology.amis.nl/blog/?p=2070

  • Select lines from DB where keys not already selected

    This must have been asked many times, but I haven't been able to find an answer:
    How do I best select a large number of entries from a table X where the keys of X
    are not already cached in a (also large) internal table t?
    There are three possibilities I can think of, one of which doesn't actually work, although
    I think it should.
    1. Convert t to a range table, where all entries have the form sign=E option=EQ (or
    sign=I option=NE - I'm confused about the difference in meaning. Which is right?)
    2. Use "for all entries". The documentation of FAE leads me to believe that this
    should be possible, because the docs only talk of using logical expressions in general
    with FAE, not equality specifically. However, using inequality does not give the right result,
    i. e.
    select * from X for all entries in t where k NE t-k
    does not work. Am I missing something?
    3. Do a select loop and read t before accepting a line. Although t is a hash table, this is
    probably the worst as regards performance.
    -- Sebastian

    In the 2nd option, just check the statment
    select * from X into table itab for all entries in t where k NE t-k

  • Create Table Trigger to replicate data from MSSQL2K5 to Oracle 11G on Linux

    I am trying to create a trigger on my MSSQL 2k5 server so that when a record is inserted, a replicated record is created in a table on an Oracle 11g database on a Linux server (Oracle Linux 6).
    Creating the trigger is easy, but when I test it I am getting an error stating the following:
    .NetSqlClient Data Provider The operation could not be performed because OLE DB Provider 'OraOLEDB.Oracle' for linked server "<myserver>" was unable to begin the distributed transaction.
    OLEDB Provider "OraOLEDB.Oracle" for linked server "<myserver>" returned: "New transaction cannot enlist in the specified transaction coordinator"
    Here is the trigger (MSSQL):
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE insert_aban8_state
        @an8 int,
        @st nvarchar(3)
    AS
    BEGIN
        SET NOCOUNT ON;
        declare @c numeric
        select @c = count(*) from [e9db]..[CRPDTA].[ABAN8_STATE$] where alan8=@an8 and aladds=@st
        if(@c =0)
         begin
            insert into [e9db]..[CRPDTA].[ABAN8_STATE$]
            values(@an8, @st)
         end
        END
    GO
    After reviewing the MS Transaction Coordinator, I am now totally confused. I checked the services and have the MS DTC enabled and running, but am not sure what to do on the Linux side.
    Does the Oracle Services for Microsoft Transaction Server (OraMTS) work on Linux? I could only find references for this for Oracle 11g on Windows.
    What do I need to do to enable this replication via mssql table trigger to Oracle11g on Linux?

    nsidev wrote:
    While I would agree in part, it appears from the message that the trigger is requiring the Transaction Service to be enabled on both the host and target. The point of this post is to determine what, if anything, I need to do on my Oracle DB to allow the trigger to complete successfully.
    There are many posts found with Google concerning the OraMTS service on the Oracle system, but they all appear to be for Windows based systems. My question is, is this service part of the Linux based Oracle DB and if so, how do I initialize it?
    If I am mistaken and this is truly an issue with the MSSQL server, I will replicate the post in those forums. I am just looking for direction and help.
    1) I have NEVER heard that Oracle has, knows about, or supports any "Transaction Service".
    2) Consider what I previously posted regarding the flavor of client source.
    If your assertion about this mythical service were correct, then the Oracle DB would have to be able to "know" that this client connection was originated by SQL Server.
    I don't understand how or why Oracle should behave differently depending upon whether INSERT is done inside or outside a MS SQL Server trigger.
    Please explain & elaborate why Oracle should behave different depending upon the source of any INSERT statement.
    3) From Oracle DB standpoint an INSERT is an INSERT; regardless of the client.

Maybe you are looking for