Query in sqlplus

how can i query in oracle 9i using sqlplus to get the fields in each table

select column_name from user_tab_columns where table_name = 'YOUR_TABLE_NAME' ;

Similar Messages

  • Oracle Spatial Query from SQLPLUS deteriorates in performance

    Hi,
    I am running an sql-procedure, which does spatial queries. When I run this procedure (from SQLPLUS) for the first time it takes around 45 sec to complete, but when I run the same procedure for the second time it takes 65 seconds and the performance keeps on decreasing. But if I open a new SQLPLUS session it takes 45 secs and it also starts deteriorating subsequently. This strange behaviour is only for spatial queries, if I don't have spatial queries in my procedure then its fine.
    I found this behaviour for any type of spatial query.
    Is there something which can be done for improving it ? I found a lot of information on improving performance of a query, but my problem is to maintain the same performance of the same query in the same session.
    Thanks,
    Rishi

    Hi,
    Could you provide version information?
    Also, could you try monitoring memory as the procedure is running an see
    if memory climbs more each time the procedure is run?
    Thanks

  • How to avoid @ for running a sql query in sqlplus

    Hi friends,
    Is there a way to avoid typing @ for the execution of every sql script in the database. Maybe playing around with the login.sql or something.
    I am bored of typing shift+@ every execution of running any of my scripts(i have nearly 3000 scripts) :(. May sound like a request from a lazy guy , but still can anyone please suggest some solution.??
    like instead of
    14:12:04 sa@TESTDB> @active
                                                                     Client                                                 last
       SID   SER# LOGON_AT        USERNAME   OSUSER     MACHINE      PID      MODULE               PROGRAM    SQL_ID        call et
       225      1 17-jun 07:00               oracle     tkxti019      4543                          oracle@tkxt                 55h 11m 43s
       224      1 17-jun 07:00               oracle     tkxti019      4651                          oracle@tkxt                 55h 11m 43s
       223      1 17-jun 07:00               oracle     tkxti019      4708                          oracle@tkxt                 55h 11m 43ssomething like below is needed
    14:12:05 sa@TESTDB> active
                                                                        Client                                                 last
       SID   SER# LOGON_AT        USERNAME   OSUSER     MACHINE      PID      MODULE               PROGRAM    SQL_ID        call et
       225      1 17-jun 07:00               oracle     tkxti019      4543                          oracle@tkxt                 55h 11m 43s
       224      1 17-jun 07:00               oracle     tkxti019      4651                          oracle@tkxt                 55h 11m 43s
       223      1 17-jun 07:00               oracle     tkxti019      4708                          oracle@tkxt                 55h 11m 43sThanks,
    Kunwar

    Kunwar wrote:
    I am bored of typing shift+@ every execution of running any of my scripts(i have nearly 3000 scripts)If you're running several scripts in one go, why not put them into a script, so that you only have to call that script and the rest will run automatically?
    eg:
    main.sql:
    Prompt Running script1
    @script1
    Prompt Running script2
    @script2
    Prompt Running script3000
    @script3000
    SQL> @main
    Running script1
    Running script2
    Running script3000
    ...

  • Column headers in SQLPLUS query

    Hi I am running a simple SQL query in SQLPLUS, and I want the column headers to appear just once at the top.
    If I set the 'SET PAGESIZE' to 50000 (which I thought was the max) it repeats the column headers evert 50000 lines.
    If I set 'SET PAGESIZE 50001', the column header appears every 14 lines
    Anyone help ?
    Thanks
    Mike
    Here is my SQLPLUS statement
    SET HEADING ON
    SET PAGESIZE 50001
    SET LINESIZE 80
    SET TERMOUT OFF
    SET VERIFY OFF
    SET FEEDBACK OFF
    SET TRIMS OFF
    SET COLSEP "|"
    SET CONCAT "."
    SET CONCAT "!"
    set newpage none
    set underline off
    SPOOL &1
    column Product format a4
    column Division format a3
    column Company format a4
    column Geography format a4
    column Customer format a12
    column Currency format a3
    column Year format a4
    column Account format a7
    column Period format a3
    SELECT /*+ index(GB,GL_BALANCES_N2) */
    'P'||GCC.SEGMENT8 Product,
    'D'||GCC.SEGMENT4 Division,
    'C'||GCC.SEGMENT1 Company,
    'G'||GCC.SEGMENT5 Geography,
    'G'||GCC.SEGMENT7 Customer,
    '&2' Currency,
    'FY'||substr(GB.PERIOD_NAME,5,2) Year,
    'A'||GCC.SEGMENT2 Account,
    substr(GB.PERIOD_NAME, 1, 3) Period,
    trim(to_char(SUM((NVL(GB.PERIOD_NET_DR,0)-NVL(GB.PERIOD_NET_CR,0))*DECODE(SUBSTR(GCC.SEGMENT2,1,1),'4',(-1),1)),'999999999990.99')) VALUE
    FROM
    GL.GL_BALANCES GB,
    GL.GL_CODE_COMBINATIONS GCC
    WHERE GCC.CHART_OF_ACCOUNTS_ID=101
    AND GB.CODE_COMBINATION_ID=GCC.CODE_COMBINATION_ID
    AND GB.SET_OF_BOOKS_ID = &3
    AND GB.ACTUAL_FLAG = 'A'
    AND GB.CURRENCY_CODE = '&2'
    AND GCC.SEGMENT2 BETWEEN '400000' AND '999999'
    AND NOT (GCC.SEGMENT2 BETWEEN '899501' AND '899506')
    AND GCC.SEGMENT2 != '899999'
    AND GB.PERIOD_NAME in &4
    GROUP BY
    'P'||GCC.SEGMENT8,
    'D'||GCC.SEGMENT4,
    'C'||GCC.SEGMENT1,
    'G'||GCC.SEGMENT5,
    'G'||GCC.SEGMENT7,
    '&2',
    'FY'||substr(GB.PERIOD_NAME,5,2),
    'A'||GCC.SEGMENT2,
    substr(GB.PERIOD_NAME, 1, 3)
    HAVING SUM(NVL(GB.PERIOD_NET_DR,0)) - SUM(NVL(GB.PERIOD_NET_CR,0)) <> 0
    ORDER BY
    'P'||GCC.SEGMENT8,
    'D'||GCC.SEGMENT4,
    'C'||GCC.SEGMENT1,
    'G'||GCC.SEGMENT5,
    'G'||GCC.SEGMENT7,
    '&2',
    'FY'||substr(GB.PERIOD_NAME,5,2),
    'A'||GCC.SEGMENT2,
    substr(GB.PERIOD_NAME, 1, 3);
    spool off
    exit

    Hi,
    Ranzalman wrote:
    Hi I am running a simple SQL query in SQLPLUS, and I want the column headers to appear just once at the top.
    If I set the 'SET PAGESIZE' to 50000 (which I thought was the max) it repeats the column headers evert 50000 lines.
    If I set 'SET PAGESIZE 50001', the column header appears every 14 linesApparantly, 50,000 lines is the max. If you try to set PEGESIZE higher than that, you get the default, which is 14.
    The best thing might be to SET PAGESIZE 0, which turns off paging. Unfortunately, that turns off the automatic headers, too, so you'll have to supply your own header, manually, like this:
    SPOOL  &1
    SET   PAGESIZE    0
    PROMPT  PROD|DIV|COMP|GEOG|CUSTOMER    |CUR|YEAR|ACCOUNT|PER|VALUE
    SELECT /*+ index(GB,GL_BALANCES_N2) */
    ...

  • Sqlplus command using a query instead of a sql file

    can any body guide me?..i want to execute the sql query using sqlplus without using a sql file. for example following command is valid:
    sqlplus abc/abc@abc @abc.sql
    but i want
    sqlplus abc/abc@abc @(select * from abc)
    i will be thankful if any body can suggest something
    Message was edited by:
    syed.habib
    Message was edited by:
    syed.habib

    i use the suggested command in a batch file and when i run this command, i get this:
    C:\>(
    echo select count(*) from tab
    More? echo /
    More? echo exit
    ) | sqlplus -s abc/abc@abc
    'More?' is not recognized as an internal or external command,
    operable program or batch file.
    'More?' is not recognized as an internal or external command,
    operable program or batch file.

  • Sql query is running fast in sqlplus but too slow in oracle why?

    Hi,
    I am executing one query in sqlplus . it gives output in two mins. when run that query in oracle it takes above 7hrs. why?
    what is root cause of this problem?

    SQLPLUS is a part of Oracle :) Do you mean SQL server
    Edited by: Maran.Viswarayar on Apr 19, 2010 11:49 PM

  • How could I  export a sqlplus query to a .txt file?

    Hi,
    I have an Oracle 10g database running on a linux e3 server.
    I have generated a SQL query using sqlplus on the server site, so the result is under the SQL>
    How could I export it to a .txt?
    Thanks a lot!
    Any advice is highly appreciated!
    Qian

    Hi, Qian,
    In SQL*Plus, say "SPOOL filename", and all the output that appears on your screen will also be written to filename, until you say "SPOOL OFF".
    Look up SPOOL in the SQL*Plus manual for more details.

  • How to run a query on a external file on sqlplus

    It is too painfull when I have to script a large query on sqlplus.
    How can I do to save a query on a txt file and run it on sqlplus?

    make a file in c:\ say abc.sql
    save the query is it
    the
    SQL>@c:\abc.sql
    So simple

  • How to pass a date parameter from report builder query designer to oracle database

    i'm using report builder 3.0 connected to oracle database. i'm trying to pass a date parameter in the query with no success, i don't
    know the exact syntax. I've tried :
    SELECT * FROM igeneral.GCL_CLAIMS where CREATED_BY IN (:CREATED_BY) AND CLAIM_YEAR IN(:UW_YEAR) AND (LOSS_DATE) >To_Date('01/01/2014','mm/dd/yyyy')
    it worked perfectly.
    However if i try to put a date parameter "From" instead of 01/01/2014 it will not work, a Define Query Parameter popup window appear and error occurred after i fill
    the values (usually i shouldnt get this popup i should enter the value when i run the report)
    SELECT * FROM igeneral.GCL_CLAIMS where CREATED_BY IN (:CREATED_BY) AND CLAIM_YEAR IN(:UW_YEAR) AND (LOSS_DATE) >To_Date(:From,'mm/dd/yyyy')
    appreciate your assistance

    Hi Gorgo,
    According to your description, you have problem when in passing a parameter for running a Oracle Query. Right?
    Based on my knowledge, it use "&" as synax for parameter in Oracle, like we use "@" in SQL Server. In this scenario, maybe you can try '01/01/2014' when inputing in "From". We are not sure if there's any limitation for To_Date()
    function. For your self-testing, you can try the query in sqlplus/sql delveloper. Since your issue is related to Oracle query, we suggest you post this thread onto Oracle forum.
    Best Regards,
    Simon Hou

  • Using a query with bind variable with columns defined as raw

    Hi,
    We are on Oracle 10.2.0.4 on Solaris 8. I have a table that has 2 columns defined as raw(18). I have a query from the front end that queries these two raw columns and it uses bind vairables. The query has a performance issue that I need to reproduce but my difficulty is that how to test the query in sqlplus using bind variables (the syntax for bind vairables fails for columns with raw datatype).
    SQL> DESC TEST
    Name                                      Null?    Type
    ID1                                                RAW(18)
    ID2                                                RAW(18)
    SQL> variable b1  RAW(18);
    Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
                        VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
                        NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
                        BINARY_FLOAT | BINARY_DOUBLE ] ]
    The above is the error I get - i cant declare a variable as raw.
    SQL> variable b2  RAW(18);
    Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
                        VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
                        NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
                        BINARY_FLOAT | BINARY_DOUBLE ] ]
    SQL> variable b3  RAW(18);
    Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
                        VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
                        NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
                        BINARY_FLOAT | BINARY_DOUBLE ] ]
    --now the actual query below
    SQL> SELECT * FROM TEST WHERE ID1=:B1 AND ID2 BETWEEN :B2 AND :B3;
    SP2-0552: Bind variable "B3" not declared.
    (this fails due to the errors earlier)Also this is a third party app schema so that we don't have the option of modifying the data type of the columns.
    Thanks,
    Edited by: orausern on May 10, 2011 11:30 AM

    Try anonymous PL/SQL block:
    declare
    b1 RAW(18);
    b2 RAW(18);
    b3 RAW(18);
    begin
    b1:=..;
    b2:=..;
    b3:=..;
    SELECT col1, col2, ..
    INTO ...
    FROM TEST
    WHERE ID1=:B1
    AND ID2 BETWEEN :B2 AND :B3;
    end;
    /

  • How to schedule a sql query on Windows

    Hi Experts;
    I got a sql query that I need to put on schedule, (on windows) in order it runs everyday at specific time.
    I got the query, but I want to know the next:
    How to invoke SQLPlus from this query? Explain how to include the user/password@SID
    Do I need to create this query in a .bat file?
    Also I want to know, how to send the results to an email?
    Thanks for your help.
    Regards
    Al

    I would suggest to put your sql query to a separate file and spool the result to a concrete file:
    query.sql:
    spool query.lst
    select * from emp;
    spool off;create a bat file query.bat:
    sqlplus <connection> @query.sql
    ...work with content of query.lst, send mail etcThen schedule your bat file with Windows scheduler
    The above could be simplified with JavaScript or VBScript
    Thanks.

  • Report parameter from query

    Hi,
    The distribution file uses parameters from the query in the report
    The problem is that if no records match it means that when it tries to resolve &amp;&lt;report_id it can't and generates the following error
    Terminated with error: REP-34308: Invalid reference parameter 'report_id' in distribution list
    Does anyone know how I can check if this is null in the distribution file?
    <foreach>
    <destype id="blob1" name="blobdestination" instance="this" format="pdf">
    <property name="desname"
    value="http://host:port/prod/*&amp;&lt;report_id>*/&amp;&lt;key_val>/&amp;&lt;FileName>/&amp;&lt;Type>"/>
    <include src="mainSection"/>
    </destype>
    </foreach>

    Hi Gorgo,
    According to your description, you have problem when in passing a parameter for running a Oracle Query. Right?
    Based on my knowledge, it use "&" as synax for parameter in Oracle, like we use "@" in SQL Server. In this scenario, maybe you can try '01/01/2014' when inputing in "From". We are not sure if there's any limitation for To_Date()
    function. For your self-testing, you can try the query in sqlplus/sql delveloper. Since your issue is related to Oracle query, we suggest you post this thread onto Oracle forum.
    Best Regards,
    Simon Hou

  • Crystal Report XI: Can you write your query in SQL instead of using the GUI

    Hello
      In crystal report version XI, can you write your query in sqlplus and then use the crystal report designer to build your report instead of using the GUI . I would like to be able to go database and show sql query and open that query and make changes directly there, is that possible on this version, if yes is there a setting somewhere? Please let me know.
    Thank you
    alpha

    Moved to Database forum.
    No you can no longer modify the SQL directly. Use a Command Object to enter the SQL directly.
    Thank you
    Don

  • Getting error in 9.2.0.4.0 Pro*c version while running the query.

    HI All,
    I am using oracle database 9.2.0.4.0. Previously we are using the oracle version Release 8.0.6.3.0. In this version Pro*c we have a query like below:
    SELECT a.trn_id, a.i_cd, a.mfg_cd, a.co,
    TO_CHAR (a.i_date, 'YYYYMMDD'), a.store, a.pur_num,
    TO_CHAR (a.terms_date, 'YYYYMMDD'), a. amt, a.i_amt,
    TO_CHAR (a.due_dt, 'YYYYMMDD'), COUNT (b.trn_id)
    FROM t_abc_ln b, t_abc a
    WHERE b.trn_id(+) = a.trn_id AND a.orig_cd = 'RECUR'
    GROUP BY a.trn_id,
    a.i_cd,
    a.mfg_cd,
    a.co,
    a.i_date,
    a.store,
    a.pur_num,
    a.terms_date,
    a. amt,
    a.i_amt,
    a.due_dt
    ORDER BY a.trn_id ASC;
    was working fine. But in the new version 9.2.0.4.0 the above query in the Pro*C is not working properly.
    It is throughing the error
    Fatal Error: File: C_ABC_CURDB.cpp Line: 431
    Not Found
    sqlerrd[4]: SQL parse error, offset: 0
    sqlerrd[2]: Rows Processed: 4
    **** Abnormal Termination ****
    Failure happens at the time of FETCHing the cursor, whereas OPEN cursor is successful. When I remove outer join above query i.e., program runs fine without any errors. Rows Processed is equal to number rows in the t_abc table. Running the above query on SQLPLUS executes fine.
    How this could be resolved to make it to work on Pro* C/C++ version 9.2.0.4.0? are is it a limitation on this version? Do we need to re-write the query by removing the outer join?
    Thanks,
    SUN

    If an XML document has a dtd definition, the document is validated with the dtd.
    Remove the DOCTYPE definition by applying an XSLT.
    <xsl:template match="/">
       <xsl:copy-of select="." />
    </xsl:template>

  • ORA-01041 Error while query in PL/SQl Developer

    Hi All,
    I am trying to execute a simple select statement in PL/SQL developer. After the query gets executed i am getting a error
    ORA-01041 internal error. hostdef extension doesn`t exist.
    But when i perform the same query in sqlplus, i do not receive this kinda error.
    Does any 1 have a idea on this error?
    Regards,
    Ritesh Khuller

    PL/SQL Developer is a third-party tool and not from oracle.
    maybe you have better chances in the rdbms-forum where they know more about hostdef's
    PL/SQL
    General Database Discussions

Maybe you are looking for