SQL*Plus: Comment appears in Default-Column

Please look at this commands, executed in SQL*Plus (Oracle 10g):
create table t1 (
c1 number,
c2 number default 0 -- comment in sqlplus
select column_name,data_default from all_tab_columns where table_name='T1';
COLUMN_NAME                    DATA_DEFAULT
C1
C2                             0 -- comment in sqlplus
The comment is stored in the data dictionary! ?:|
insert into t1 (c1) values (0);
commit;
But the default clause works:
select c1,c2 from t1;
C1        C2
+0 0+
Is it a bug or is it a feature???
Greetings from Germany
Wolfgang

From: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_constraints.htm#sthref626
Setting Default Column Values
Default values can be defined using any literal
Bug or feature?
It depends on how literal you interprete literals?
!http://www.designer-daily.com/wp-content/uploads/2009/06/bug-feature.jpg!

Similar Messages

  • SQL * PLUS - setting wrap on for column

    hi all, i am playing around with sql plus and i encountered the following problem.
    1) is length 10 the default column length for columns with number datatype in sqlplus, i done a select statement and all my column for number have a length of 10
    2) why cant i format the length of a number column. i type column empno format 999
    although my numbers become #### but "empno" and a length of 10 is still shown at the column name instead of just "emp"
    3) how come a column name canot be wrapped
    when i set wrap on.
    set wrap on
    column ename format a3
    only the values of ename are wrap
    but the column name "ename" isnt wrap
    into ena
    me
    thanks.

    Some examples :
    TEST@db102 > select 1234567890123 from dual;
    1234567890123
       1.2346E+12
    TEST@db102 > set numwidth 15
    TEST@db102 > /
      1234567890123
      1234567890123
    TEST@db102 > col ename for a3 wrapped
    TEST@db102 > select ename from emp where empno=7902;
    ENA
    FOR
    D
    TEST@db102 > You can find everything in the documentation

  • SQL*Plus variable assignment works for 8i but not 9i

    We have scripts that connect to each database on the box and perform database tasks nightly. The scripts first set the environment then connects to each database with SQL*Plus. This works for 8i but fails in the recently created 9i environment. (Unix Solaris environment)
    Because the SQL*Plus connection appears in many areas in the scripts, we assign the following connection string to a variable:
    SQLPLUS="/usr/oracle/product/9.2.0/bin/sqlplus -s 'xxx/xxxxxx@xxxx as sysdba'"
    Export SQLPLUS
    echo "$SQLPLUS"
    (This echo out correctly: /usr/oracle/product/9.2.0/bin/sqlplus -s 'xxx/xxxxxx@xxxx as sysdba')
    It fails when the script calls the assigned variable:
    $SQLPLUS <<-EOF
    with the following error:
    Usage: SQLPLUS [ [<option>] [<logon>] [<start>] ]
    where <option> ::= -H | -V | [ [-L] [-M <o>] [-R <n>] [-S] ]
    <logon> ::= <username>[<password>][@<connect_string>] | / | /NOLOG
    <start> ::= @<URI>|<filename>[.<ext>] [<parameter> ...]
    "-H" displays the SQL*Plus version banner and usage syntax
    "-V" displays the SQL*Plus version banner
    "-L" attempts log on just once
    "-M <o>" uses HTML markup options <o>
    "-R <n>" uses restricted mode <n>
    "-S" uses silent mode
    However, if I remove the SQLPLUS variable assignment and changed all occurrence of
    $SQLPLUS <<-EOF to
    /usr/oracle/product/9.2.0/bin/sqlplus -s 'xxx/xxxxxx@xxxx as sysdba' <<-EOF
    Then the script runs successfully. But this solution is cumbersome.
    Any ideas as to how to have the script work with assigning the SQLPLUS variable????
    Any help is appreciated.

    I has an immediate suspicion it might be related to the issue
    mentioned in
    http://otn.oracle.com/support/tech/sql_plus/htdocs/sub_var2.html#2_7
    but this proved wrong: the SP2-306 still occurs in the latest
    SQL*Plus.
    I wonder what version of 8i you had working? With an old SQL*Plus
    8.1.7.0 my connection failed the same as in 9.2 and 10i.
    My solution was to do:
      SQLPLUS='sqlplus -s'
      UNPW='/ as sysdba'
      $SQLPLUS "$UNPW" &lt;&lt;EOF
      EOFThis worked in 9.2.0.5, 10.1.0.2 and 8.1.7.0.
    One common security risk on UNIX remains: putting the username and
    password on the command line. On some systems a "ps" command will
    show the password to any user. If OS authentication cannot be used
    for connection, perhaps putting the username/password in the SQL
    script may be more secure?
    A final note is that in SQL*Plus 10g, no quotes are needed around
    AS SYSDBA, i.e.
      sqlplus / as sysdba works from the OS prompt, whereas in 9.2 you need to do
      sqlplus "/ as sysdba"This makes a solution easy:
      SQLPLUS="/usr/oracle/product/10.1.0/bin/sqlplus -s xxx/xxxxxx@xxxx as sysdba"-- CJ

  • SQL*Plus assignment works for 8i but not 9i

    We have scripts that connect to each database on the box and perform database tasks nightly. The scripts first set the environment then connects to each database with SQL*Plus. This works for 8i but fails in the recently created 9i environment.
    Because the SQL*Plus connection appears in many areas in the scripts, we assign the following connection string to a variable:
    SQLPLUS="/usr/oracle/product/9.2.0/bin/sqlplus -s 'xxx/xxxxxx@xxxx as sysdba'"
    Export SQLPLUS
    echo "$SQLPLUS"
    (This echo out correctly: /usr/oracle/product/9.2.0/bin/sqlplus -s 'xxx/xxxxxx@xxxx as sysdba')
    It fails when the script calls the assigned variable:
    $SQLPLUS <<-EOF
    with the following error:
    Usage: SQLPLUS [ [<option>] [<logon>] [<start>] ]
    where <option> ::= -H | -V | [ [-L] [-M <o>] [-R <n>] [-S] ]
    <logon> ::= <username>[<password>][@<connect_string>] | / | /NOLOG
    <start> ::= @<URI>|<filename>[.<ext>] [<parameter> ...]
    "-H" displays the SQL*Plus version banner and usage syntax
    "-V" displays the SQL*Plus version banner
    "-L" attempts log on just once
    "-M <o>" uses HTML markup options <o>
    "-R <n>" uses restricted mode <n>
    "-S" uses silent mode
    However, if I remove the SQLPLUS variable assignment and changed all occurrence of
    $SQLPLUS <<-EOF to
    /usr/oracle/product/9.2.0/bin/sqlplus -s 'xxx/xxxxxx@xxxx as sysdba' <<-EOF
    Then the script runs successfully. But this solution is cumbersome.
    Any ideas as to how to have the script work with assigning the SQLPLUS variable????
    Any help is appreciated

    I has an immediate suspicion it might be related to the issue
    mentioned in
    http://otn.oracle.com/support/tech/sql_plus/htdocs/sub_var2.html#2_7
    but this proved wrong: the SP2-306 still occurs in the latest
    SQL*Plus.
    I wonder what version of 8i you had working? With an old SQL*Plus
    8.1.7.0 my connection failed the same as in 9.2 and 10i.
    My solution was to do:
      SQLPLUS='sqlplus -s'
      UNPW='/ as sysdba'
      $SQLPLUS "$UNPW" &lt;&lt;EOF
      EOFThis worked in 9.2.0.5, 10.1.0.2 and 8.1.7.0.
    One common security risk on UNIX remains: putting the username and
    password on the command line. On some systems a "ps" command will
    show the password to any user. If OS authentication cannot be used
    for connection, perhaps putting the username/password in the SQL
    script may be more secure?
    A final note is that in SQL*Plus 10g, no quotes are needed around
    AS SYSDBA, i.e.
      sqlplus / as sysdba works from the OS prompt, whereas in 9.2 you need to do
      sqlplus "/ as sysdba"This makes a solution easy:
      SQLPLUS="/usr/oracle/product/10.1.0/bin/sqlplus -s xxx/xxxxxx@xxxx as sysdba"-- CJ

  • Sql plus password typing problem

    Hello there
    I'm trying to access sql plus 11g on windows 7, i correctly write the username but when i try to type the password, nothing is typed at all, not letters nor asteresks!!
    plz help meee

    C:\Users\lord>sqlplus / as sysdba SELECT * V$VERSION;
    SQL*Plus: Release 11.2.0.3.0 Production
    Copyright (c) 1982, 2011, Oracle. All rights reserved.
    Use SQL*Plus to execute SQL, PL/SQL and SQL*Plus statements.
    Usage 1: sqlplus -H | -V
    -H Displays the SQL*Plus version and the
    usage help.
    -V Displays the SQL*Plus version.
    Usage 2: sqlplus [ [<option>] [{logon | /nolog}] [<start>] ]
    <option> is: [-C <version>] [-L] [-M "<options>"] [-R <level>] [-S]
    -C <version> Sets the compatibility of affected commands to the
    version specified by <version>. The version has
    the form "x.y[.z]". For example, -C 10.2.0
    -L Attempts to log on just once, instead of
    reprompting on error.
    -M "<options>" Sets automatic HTML markup of output. The options
    have the form:
    HTML ON [HEAD text] [BODY text] [TABLE text]
    [ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] ON]
    -R <level> Sets restricted mode to disable SQL*Plus commands
    that interact with the file system. The level can
    be 1, 2 or 3. The most restrictive is -R 3 which
    disables all user commands interacting with the
    file system.
    -S Sets silent mode which suppresses the display of
    the SQL*Plus banner, prompts, and echoing of
    commands.
    <logon> is: {<username>[<password>][@<connect_identifier>] | / }
    [AS {SYSDBA | SYSOPER | SYSASM}] [EDITION=value]
    Specifies the database account username, password and connect
    identifier for the database connection. Without a connect
    identifier, SQL*Plus connects to the default database.
    The AS SYSDBA, AS SYSOPER and AS SYSASM options are database
    administration privileges.
    <connect_identifier> can be in the form of Net Service Name
    or Easy Connect.
    @[<net_service_name> | [/]Host[:Port]/<service_name>]
    <net_service_name> is a simple name for a service that resolves
    to a connect descriptor.
    Example: Connect to database using Net Service Name and the
    database net service name is ORCL.
    sqlplus myusername/mypassword@ORCL
    Host specifies the host name or IP address of the database
    server computer.
    Port specifies the listening port on the database server.
    <service_name> specifies the service name of the database you
    want to access.
    Example: Connect to database using Easy Connect and the
    Service name is ORCL.
    sqlplus myusername/mypassword@Host/ORCL
    The /NOLOG option starts SQL*Plus without connecting to a
    database.
    The EDITION specifies the value for Session Edition.
    <start> is: @<URL>|<filename>[.<ext>] [<parameter> ...]
    Runs the specified SQL*Plus script from a web server (URL) or the
    local file system (filename.ext) with specified parameters that
    will be assigned to substitution variables in the script.
    When SQL*Plus starts, and after CONNECT commands, the site profile
    (e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql) and the user profile
    (e.g. login.sql in the working directory) are run. The files may
    contain SQL*Plus commands.
    Refer to the SQL*Plus User's Guide and Reference for more information.
    C:\Users\lord>

  • SQL Plus Crashes.

    If I mistype a query in the SQL Plus window (say a wrong column name) it crashes.
    This is happenning with my new installation of Oracle8i 8.1.7 EE on Windows 2000 Pro.
    Any Ideas?
    Thanks.

    It's not possible to connect from 10g to 7.3.4, but it works until client version 9.2.0.
    Client / Server / Interoperability Support Between Different Oracle Versions
    Doc ID: Note:207303.1
    Werner

  • Question about setting column width in SQL*Plus using info retrieved w SQL

    Good morning,
    Is there a way to tell SQL*Plus to set the width of a column to the greatest width of the elements found in the column ? (as opposed to the default which is the width declared in the DDL)
    In other words, I'd like to do something functionally equivalent to this:
    COL <columname> format a[select max(length(<columnname>)) from <thetablethatcontainscolumname>]
    I'm doing the above manually in two steps
    1. select max(length(columnname)) from .....
    2. col columnname format a[resultofstep1]
    Is there a way of doing it in one step ?
    Thank you for your help,
    John.

    Hi Munky,
    >
    you should consider whther you are using the correct tool for the job, SQLplus isn't exactly ideal for doing presentation layer stuff
    >
    I'm not really doing presentation stuff, I asked because it would be very convenient for everyday stuff. I commonly query the tables that I am going to deal withm just to have a look at the column names and a few values, something like:
    select * from EMP where rownum <= 10; -- just to have a look at the table and some values
    when the table contains a wide column then the display gets all messed up. It would be nice to have an option or a mechanism to tell SQL*Plus to automatically use the width of the widest value, instead of having to determine the value and then manually set the column.
    thank you for your help, it's good to know that I didn't miss some trivial setting in the documentation that would do it ;)
    John.

  • Oracle SQL Developer 3.2, SQL*Plus COLUMN FORMAT bug

    SQL*Plus command COLUMN truncates output result in SQL Developer.
    Script in Worksheet:
    column nn format 999
    select level nn from dual connect by level<=10;The Run Script (F5) result contains only 8 lines in Script Output window:
    NN
    1
    2
    3
    4
    5
    6
    7
    8
    Changing column alias:
    select level nn2 from dual connect by level<=10NN2
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    10 rows selected
    The output can contain no data for more formatted columns.
    ===============================================================
    About
    Oracle SQL Developer 3.2.09
    Version 3.2.09
    Build MAIN-09.30
    Copyright © 2005, 2012 Oracle. All Rights Reserved.
    IDE Version: 11.1.1.4.37.59.48
    Product ID: oracle.sqldeveloper
    Product Version: 11.2.0.09.30
    Version
    Component     Version
    =========     =======
    Java(TM) Platform     1.7.0_02
    Oracle IDE     3.2.09.30
    Versioning Support     3.2.09.30

    sqldeveloper64-3.2.09.30-no-jre.zip.
    My jdk now is 1.7.07 x64, Windows 7 x64.
    C:\Java\jdk17\bin>java -version
    java version "1.7.0_07"
    Java(TM) SE Runtime Environment (build 1.7.0_07-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
    Gary Graham wrote:Also, I don't understand what you mean by
    The output can contain no data for more formatted columns.
    Sript:
    col owner format a10
    col table_name format a20
    col column_name format a20
    col comments format a50
    select
       row_number() over(order by column_name) r11,   
       count(*) over() c11,
       owner ow,
       table_name tn,
       column_name cn,
       comments co
    from all_col_comments t
    where owner='SYS' and table_name='INDEX_STATS';
    select
       row_number() over(order by column_name) r,   
       count(*) over() c,
       owner,
       table_name,
       column_name,
       comments
    from all_col_comments t
    where owner='SYS' and table_name='INDEX_STATS';
    select 1 from dual;
    prompt abcThe output truncated after headers of second queryR11 C11 OW                             TN                             CN                             CO                                                                                                                                                        
      1  25 SYS                            INDEX_STATS                    BLKS_GETS_PER_ACCESS           Expected number of consistent mode block gets per row. This assumes that a row chosen at random from the table is being searched for using the index
      2  25 SYS                            INDEX_STATS                    BLOCKS                         blocks allocated to the segment                                                                                                                    
      3  25 SYS                            INDEX_STATS                    BR_BLKS                        number of branch blocks in the b-tree                                                     
      4  25 SYS                            INDEX_STATS                    BR_BLK_LEN                     useable space in a branch block                                                           
      5  25 SYS                            INDEX_STATS                    BR_ROWS                        number of branch rows                                                                     
      6  25 SYS                            INDEX_STATS                    BR_ROWS_LEN                    sum of the lengths of all the branch blocks in the b-tree                                 
      7  25 SYS                            INDEX_STATS                    BTREE_SPACE                    total space currently allocated in the b-tree                                             
      8  25 SYS                            INDEX_STATS                    DEL_LF_ROWS                    number of deleted leaf rows in the index                                                  
      9  25 SYS                            INDEX_STATS                    DEL_LF_ROWS_LEN                total length of all deleted rows in the index                                             
    10  25 SYS                            INDEX_STATS                    DISTINCT_KEYS                  number of distinct keys in the index                                                      
    11  25 SYS                            INDEX_STATS                    HEIGHT                         height of the b-tree                                                                      
    12  25 SYS                            INDEX_STATS                    LF_BLKS                        number of leaf blocks in the b-tree                                                       
    13  25 SYS                            INDEX_STATS                    LF_BLK_LEN                     useable space in a leaf block                                                             
    14  25 SYS                            INDEX_STATS                    LF_ROWS                        number of leaf rows (values in the index)                                                 
    15  25 SYS                            INDEX_STATS                    LF_ROWS_LEN                    sum of the lengths of all the leaf rows                                                   
    16  25 SYS                            INDEX_STATS                    MOST_REPEATED_KEY              how many times the most repeated key is repeated                                          
    17  25 SYS                            INDEX_STATS                    NAME                           name of the index                                                                         
    18  25 SYS                            INDEX_STATS                    OPT_CMPR_COUNT                 optimal prefix compression count for the index                                            
    19  25 SYS                            INDEX_STATS                    OPT_CMPR_PCTSAVE               percentage storage saving expected from optimal prefix compression                        
    20  25 SYS                            INDEX_STATS                    PARTITION_NAME                 name of the index partition, if partitioned                                               
    21  25 SYS                            INDEX_STATS                    PCT_USED                       percent of space allocated in the b-tree that is being used                               
    22  25 SYS                            INDEX_STATS                    PRE_ROWS                       number of prefix rows (values in the index)                                               
    23  25 SYS                            INDEX_STATS                    PRE_ROWS_LEN                   sum of lengths of all prefix rows                                                         
    24  25 SYS                            INDEX_STATS                    ROWS_PER_KEY                   average number of rows per distinct key                                                   
    25  25 SYS                            INDEX_STATS                    USED_SPACE                     total space that is currently being used in the b-tree                                    
    25 rows selected
    R C OWNER      TABLE_NAME           COLUMN_NAME          COMMENTS                                        
    - - ---------- -------------------- -------------------- --------------------------------------------------

  • Comments to be displayed in SQL*PLUS....

    Hi ,
    When i issue the following command in PL/SQL Developer(third-party tool) - as user SCOTT :
    SQL> desc user_extents;
    Name            Type              Nullable Default Comments                                           
    SEGMENT_NAME    VARCHAR2(81 BYTE) Y                Name of the segment associated with the extent     
    PARTITION_NAME  VARCHAR2(30 BYTE) Y                Partition/Subpartition Name, if any, of the segment
    SEGMENT_TYPE    VARCHAR2(18 BYTE) Y                Type of the segment                                
    TABLESPACE_NAME VARCHAR2(30 BYTE) Y                Name of the tablespace containing the extent       
    EXTENT_ID       NUMBER            Y                Extent number in the segment                       
    BYTES           NUMBER            Y                Size of the extent in bytes                        
    BLOCKS          NUMBER            Y                Size of the extent in ORACLE blocks    Whereas when i issue the same command in SQL*PLUS....
    SQL> desc user_extents;
    ¼íïìá                                     Null;    Ôýðïò
    SEGMENT_NAME                                       VARCHAR2(81)
    PARTITION_NAME                                     VARCHAR2(30)
    SEGMENT_TYPE                                       VARCHAR2(18)
    TABLESPACE_NAME                                    VARCHAR2(30)
    EXTENT_ID                                          NUMBER
    BYTES                                              NUMBER
    BLOCKS                                             NUMBERHow can i get the comments in SQL*PLUS as well...?????
    I use ORA10g v.2
    Thanks....
    Sim

    Plsql developer probably issue something like this in the background:
    select col.column_name,data_type,nullable,data_default,comments
    from all_tab_columns col,all_col_comments com
    where col.table_name=com.table_name
    and col.owner=com.owner
    and col.column_name=com.column_name
    and col.owner='SYS'
    and col.table_name = 'USER_EXTENTS'You could save similar code in script in your SQLPATH and pass the object that should be described via substitution variable.
    There are really [url http://www.adp-gmbh.ch/blog/2005/september/25.html]interesting approaches on the net regarding describe customization.
    Best regards
    Maxim

  • How to change the default directory from within SQL*Plus ?

    Hello,
    I want to change the default directory directly from within SQL*Plus to be able to launch my command files with simple instructions like :
    @my_command.sql
    If I haven't launched SQL*Plus from the directory containing the file my_command.sql, how do I change the default directory to the directory of my command files ?
    I've searched through the Oracle documentation, there's no SET DEFAULTDIR or something like that. When I do a SHOW ALL, there's no variable containing the default directory.
    If you have an idea...
    regards,
    Jérôme.

    Hi Jérôme (J鲴me ?),
    You cannot directly do that, but you can use @@ instead of @ to run subscripts in the same directory as the superscript
    # head /tmp/tl30/xxx/[xyz].sql                    
    ==> /tmp/tl30/xxx/x.sql <==
    prompt call y
    @y
    prompt call z
    @@z
    quit
    ==> /tmp/tl30/xxx/y.sql <==
    prompt i am in y
    ==> /tmp/tl30/xxx/z.sql <==
    prompt i am in z
    # pwd                                             
    /root
    # sqlplus -s scott/tiger@lsc62 @/tmp/tl30/xxx/x.sql
    call y
    SP2-0310: Datei "y.sql" konnte nicht geöffnet werden
    call z
    i am in zKind regards
    Laurent Schneider
    OCM DBA

  • GREATER THAN symbol appearing as &gt ; in SQL*Plus

    Version:11.2.0.3
    OS : RHEL 5.4
    We are a Software vedor firm.We have sent our SQL files to our client to execute. But the codes for various procedures and functions were failing
    because, in their SQL*Plus session (in Putty) the LESS THAN character < was appearing as &lt ; and GREATER THAN character > was appearing as &gt ;
    In the original code which we had sent to them has no problems with > or < characters.
    Original code
    Cursor feb_cur IS
      SELECT user_pwid
        FROM carton_hdr_dtl
       WHERE MODIFIED_DATE >= D_Last_Run_Date
       UNION
      SELECT user_pwid
        FROM carton_hdr_dtl_bkp
       WHERE (modified_date >= D_Last_Run_Date OR
              deleted_date >= D_Last_Run_Date);  But in the execution log file sent by our client, I can see &gt ; instead of > character.
    54   Cursor feb_cur IS
    55    SELECT user_pwid
    56        FROM carton_hdr_dtl
    57       WHERE MODIFIED_DATE &gt ;= D_Last_Run_Date
    58       UNION
    59    SELECT user_pwid
    60        FROM carton_hdr_dtl_bkp
    61       WHERE (modified_date &gt ;= D_Last_Run_Date OR
    62              deleted_date &gt;= D_Last_Run_Date);What are they doing wrong? They use putty. We use putty too but we don't have any issues.
    Edited by: Max on Dec 17, 2012 2:42 AM

    Thank you Blushadow, Nicosa for providing this clue.
    I checked with my client. They have put our scripts in Collabnet SVN version control and the implementor DBA will be provided the http URL .
    Apparently SVN is accessed using http protocol and yes you are right it is opened through a browser by typing an URL like below
    http://10.80.16.214:79839/svn/brcf/DBfiles/2012/WMHReleasel8/hrtb_pkt_wave.sqlFor most of the end users , the GREATER THAN character appears as > without any issues . For some users it appears as &gt ; . One potential cause is the difference in Internet Explorer version. They are currently looking into this.
    THANK YOU BLUSHADOW and NICOSA for shedding light on this.
    Hi Nicosa,
    A forum formatting question:
    How did you manage to get &gt_; (without the underscore) printed ? When I tried it the forums editor was converting it to > . This is why I placed a space/underscore between t and semi colon. Is there some escape character ?

  • Can i comment out lines of code in a .sql script file to be run in SQL PLUS

    Hi All,
    I have commented out part of the script, and when i ran the script (.sql) file in Sql*Plus
    I am getting some errors like
    SP2-0734: unknown command beginning
    how to avoid these errors?
    any help is appreciated
    Thanks
    R.R

    >
    select * from dual; -- me too!Nope, not this one...
    test@ORA10G>
    test@ORA10G> host type c:\test.sql
    select * from dual; -- me too!
    test@ORA10G>
    test@ORA10G> -- doesn't work
    test@ORA10G>
    test@ORA10G> @c:\test.sql
      2
    test@ORA10G>
    test@ORA10G> @c:\test.sql
      2  /
    select * from dual; -- me too!
    ERROR at line 1:
    ORA-00911: invalid character
    test@ORA10G>
    test@ORA10G> -- now this works...
    test@ORA10G> host type c:\test.sql
    select * from dual -- me too!
    test@ORA10G>
    test@ORA10G> @c:\test.sql
    D
    X
    test@ORA10G>
    test@ORA10G> -- and so does this...
    test@ORA10G> host type c:\test.sql
    select * from dual -- me too!
    test@ORA10G>
    test@ORA10G> @c:\test.sql
    D
    X
    test@ORA10G>
    test@ORA10G>pratz

  • Set Column width in query (not using SQL*Plus)

    How can I Set Column width in query
    I understand you can set column width using
    column col1 FORMAT A5
    select col1 from table1;But this only works in SQL*Plus
    I want to be able to do this in a regular SQL query window (not in SQL*Plus), how can I do it.....
    I am using a 'SQL window' in PL/SQL Developer IDE
    and when I use this syntax it says:
    ORA-00900: Invalid SQL statement
    Any suggestions are appreciated...
    thanks,
    M.

    Did you try using RPAD or LPAD functions? They fill the unfilled part of a string with character you provide... either on right or left side depending on what function you use.
    e.g.
    SELECT RPAD('Smith', 10, ' ') Name FROM dual;http://www.adp-gmbh.ch/ora/sql/rpad.html
    Edited by: Zaafran Ahmed on Nov 10, 2010 11:50 AM

  • X.column.getStringVal() throws "invalid column name", works in SQL*Plus.

    The subject sums it up pretty well... I have a query that works fine from SQL*Plus, but throws a JDBC exception with "ORA-00904 invalid column name" if I create a PreparedStatement from it and call executeQuery().
    The query itself is substantially similar to:
    SELECT foo, t.bar.getStringVal() from some_table t
    where "Some table" is an oracle 9i table, "foo" is a varchar2 column, and "bar" is a column that used to be varchar2 before I dropped and re-created the table with an xmltype column instead. "t" is an alias for the table that I didn't used to need (since it's only one table), but apparently is required for getStringVal() to work.
    ... And, of course, .getStringVal() is being used as a convenient way to treat technically LOB-like xmltype columns as big ersatz varchar2 columns so I won't have to screw around with stream i/o just to read a 4,001-byte value into a String ;-)
    I'm using the ojdbc14.jar thin driver and a fairly recent j2sdk (1.4.1_02, I think). I made a point of anihilating every copy of classes12.zip on my PC just to make sure it wasn't lurking in a classpath somewhere to screw things up.
    Strangely enough, it DOES work from within Netbeans' database explorer (itself connecting to the same Oracle database using the ojdbc14.jar thin driver).
    For the sake of being comprehensive, here's an example of the actual JDBC code that won't work:
    public ResultSet doQuery(Connection conn, int val) throws SQLException {
    String sql = "SELECT foo, t.bar.getStringVal() from some_table t where anothercolumn = ?";
    PreparedStatement sth = conn.prepareStatement(sql);
    sth.setInt(1, val);
    ResultSet rs = sth.executeQuery();
    // everything past this point is moot,
    // because sth.executeQuery throws an exception...
    // however, the ResultSet would ultimately be
    // returned to the method's caller, and
    // its values read using getString(fieldname)
    // including 'bar', the xmltype field...

    OK, this particular problem was my fault. The original table was on a server running 8i. To spare myself the grief of having to deal with CLOBs on 8i's terms and take advantage of 9i's new conveniences for handling them, I created a new table on our other server that's running 9i and updated the app's config settings to reflect the new server. Unfortunately, I forgot that the debugging/testing main() method had the URL of the old database hardcoded (it was written before the rest of the class). Ergo... it was still looking at the old database. Oops. (*blush*).

  • Display column name in sql*plus

    Hi,
    How to display full column name?
    there are n no of tables, i have to query the tables but i want the column name to be displayed fully. for example
    SQL> desc control
    Name Null? Type
    CODE NOT NULL VARCHAR2(255)
    LOAD_PERIOD_START_DATETIME DATE
    SQL> select code,load_period_start_datetime from control;
    CODE
    LOAD_PERIOD
    AAA
    01-AUG-2007
    SQL> col load_period_start_datetime format a30
    SQL> /
    CODE
    LOAD_PERIOD_START_DATETIME
    AAA
    01-AUG-2007
    SQL>
    As it is only one column i can set with 'col <column_name> format a 30'
    if there are n no of coumns from n no tables then how do i get the full column name?
    Please help me.
    Thanks

    Hi,
    you can get all the column's for a TABLE from all_tab_columns this VIEW, why dont you write as script which will generate the commands.
    Could you please tell us why do you want to display the compete COLUMN NAME in SQL plus.
    Thanks

Maybe you are looking for