SQLPLUS formatting

I have the following SQL code

Select file_name, bytes/1024/1024 * 80 of dba_data_files

I want the output for each line look like this (remove the line breaks, tabs...)  Y at - it an easy way to do it. I know you can use single quotes

around the literals

ALTER database datafile '+ DATA01/da01fmd_imkl065d/datafile/dw_daily_acct_sum.8.820408375' resize 24576 M Note size must be an integer

Thanks to all those who responded


Thank you all. Frank your example was a syntax error, so I used the following which works perfectly for me.

Select 'alter database datafile ' | ''''|| file_name | '''' || "resize".

|| TO_CHAR (trunc (bytes/1024/1024 * 0.8)) | ' m;'    from dba_data_files

Tags: Database

Similar Questions

  • sqlplus formatting / set

    Hi all

    I am creating a report with the help of SQL * Plus and shell.

    I use a lot of a shell script sql script. In my report, output, k I still see the actual query:

    SQL > select * from v version $;

    BANNER

    --------------------------------------------------------------------------------

    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production

    PL/SQL Release 11.2.0.2.0 - Production

    CORE Production 11.2.0.2.0

    AMT for Linux: Version 11.2.0.2.0 - Production

    NLSRTL Version 11.2.0.2.0 - Production

    Is it possible to remove the query and get the result of the query in my report? What SET option would do that?

    I would really appreciate any suspicion!

    Thank you so much in advance!

    M

    Hello

    Have you tried SET POSITION OFF and SET ECHO OFF?

    Cat sql_test.sh:

    sqlplus-s $login<>

    Set serveroutput on

    trigger the echo

    set the position

    Select 'Testing' to double;

    output

    ++

  • Output of sqlplus formatting

    Oracle 11.1.0.7:

    I followed SQL. But when I run it it gives me all the SQL statements and other things. How can I get just the result of select?
    sqlplus stream_mon/stream_mon << EOF!
     set head off
     set pagesize 0
     set feed off
     set echo off
     spool ${MON_FILE} append
    
     SELECT APPLY_NAME || '|NoOfErrors=' || COUNT(*) FROM DBA_APPLY_ERROR group by APPLY_NAME;
    
     select APPLY_NAME || '|Latency=' ||
         (apply_time-applied_message_create_time)*86400
      from dba_apply_progress;
    
     select QUEUE_NAME || '|SrcSpillMsgs=' || spill_msgs || chr(10) || 'SrcInMemoryMsgs=' ||  (NUM_MSGS - SPILL_MSGS)
    from V\$BUFFERED_QUEUES;
    
    SELECT APPLY_NAME || '|DestSpilledTransactions=' || MESSAGE_COUNT
      FROM DBA_APPLY_SPILL_TXN;
    
    select APPLY_NAME || '|DestTotalMessagesSpilled=' || TOTAL_MESSAGES_SPILLED from V\$STREAMS_APPLY_READER;
    
    select case when status = 'ENABLED' then CAPTURE_NAME || '|CaptureProcess=1'
               else CAPTURE_NAME || '|CaptureProcess=0'
               end
          from dba_capture;
    
    select case when status = 'ENABLED' then PROPAGATION_NAME || '|PropProcess=1'
               else PROPAGATION_NAME || '|PropProcess=0'
               end
          from dba_propagation;
    
    select case when status = 'ENABLED' then APPLY_NAME || '|AppProcess=1'
               else APPLY_NAME || '|AppProcess=0'
               end
          from dba_apply;
    
     select CAPTURE_NAME || '|CaptureErrMsg=' || replace(error_message, ' ', '_') from dba_capture;
     select PROPAGATION_NAME || '|PropErrMsg='    || replace(error_message, ' ', '_') from dba_propagation;
     select APPLY_NAME || '|ApplyErrorMsg=' || replace(error_message, ' ', '_') from dba_apply;
    
     spool off
    
    EOF!
    Out something like this
    SQL>  select QUEUE_NAME || '|SrcSpillMsgs=' || spill_msgs || chr(10) || 'SrcInMemoryMsgs=' ||  (NUM_MSGS - SPILL_MSGS)
      2  from V$BUFFERED_QUEUES;
    CAP_QUEUE|SrcSpillMsgs=0 

    sqlplus stream_mon/stream_mon<>

    not above but below
    sqlplus-s stream_mon/stream_mon<>

  • 11g Client - inconsistencies to the 16th decimal

    In the clients of TOAD, SQLPlus and ODBC numbers returned by a query are correct (max 3 digits)
    In Discoverer & according to a report, the numbers are off to the 16th decimal...
    FOR EXAMPLE:
    7.081 becomes 7.0810000000000004
    7,090 becomes 7.0999999999999994 (which is weird because the District does not work)
    7,200 becomes 7.2000000000000002

    No idea what would cause this?
    How can I query from SQLPlus (or TOAD) to confirm or not those decimal extended actually exist in the table?

    Alan3 wrote:
    Maybe I should have added this little tidbit...

    Please be as detailed as possible (it is possible). See queries etc. - use copy and paste.

    The particular table in question is an interface table which is in place for 4 years and more.
    The columns in question are of NUMBER data type.
    We just changed the PC that runs this interface to Win7 with a client 11g.

    Describe the interface. For example, in what language is it written program?

    Now we see the decimals extended with the discoverer (on any PC) and the report of the interface (an old report built from Developer 6) for example, but not from SQL, etc...

    How changing customer a pc linked to the Discoverer and reports? The database server has been improved also? (the full version of select * version of $ v ;))

    You see the same 'old' data change (of the switch).

    I want to know if there is a setting in SQLPlus or the DB client that limits the display of decimal places I can change to determine if the extent of decimal numbers in fact appears... (they should not be there at all)

    Sqlplus and db can affect the outcome, for example

    SQL> desc test
     Name                                      Null?    Type
     ----------------------------------------- -------- -------------
     A                                                  NUMBER
     B                                                  NUMBER(38,5)
    
    SQL> show numw
    numwidth 10
    SQL>
    SQL> select * from test;
    
             A          B
    ---------- ----------
         12345      12345
     123456789  123456789
        123,45     123,45
    123,456789  123,45679
         1,234      1,234
    1,23456789    1,23457
    
    6 rows selected.
    

    Values has been inserted for the two columns to test. With scale = 5 for its data type, the values of B are rounded (4th and 6th rank).

    SQL> set numw 5
    SQL> select * from test;
    
        A     B
    ----- -----
    12345 12345
    ##### #####
    123,5 123,5
    123,5 123,5
    1,234 1,234
    1,235 1,235
    
    6 rows selected.
    

    The numLargeur setting affects sqlplus formatting.

    Published by: orafad on January 5, 2011 21:44

  • How to format the sql format GET easily in sqlplus

    Hello
    I use TOAD to format my sql always (to help shift + ctrl + F). It's really frustrating because I have to format the sqls a lot all the time. I have recently joined a successful dba team and need to quickly understand the sqls.

    A member of the forum can you please suggest me a way to do it quickly in sqlplus itself?

    Thanks & take care,.
    Malika

    Anthony wrote:

    But there are situations where I have to work on machines where I can't access the internet because of procedures/etc security problems, that's why I need to find a way to quickly put the sqls in sqlplus/unix itself.

    SQL * Plus is not an editor does not support formatting of unformatted existing SQL code. It uses an external editor - and formatting you want to, must be a function or feature of the external editor. The Unix/Linux default editor is vi or vim. Emacs, kate and others can also be configured (using the EDITOR environment variable) for use with SQL * more.

    Formatting manual is often a 'good' thing that it forces you to slow down and look at each line (when the manual formatting) in the code. So they identify issues and problems that could be missed when looking at already formatted code.

  • Cannot display the column format in SQLPLUS.

    Hi all

    Why my sqlplus just displays # when I run sql > column group # format a20;

    SQL > column group # format a20;
    SQL > select group # log v$.

    GROUP #.
    ----------
    ##########
    ##########
    ##########
    ##########

    Help, please!
    Thank you!

    Welcome to the forums!

    Try:

    COLUMN group# FORMAT 9999
    

    You try to provide a column for a VARCHAR2 format, but the data type is NUMBER.

  • formatting of sqlplus

    Hi all

    In sqlplus below query returns the result in 2 rows. I want the output to be on the same line

    SELECT DISTINCT ORIGINATING_TIMESTAMP, MESSAGE_TEXT to sys. X$ DBGALERTEXT WHERE MESSAGE_TEXT AS MESSAGE_TEXT AS 'fatal %' or 'ORA-%' AND ORIGINATING_TIMESTAMP > SYSDATE-4;


    example of output:

    28 APRIL 10 07.03.29.925 H + 03:00
    ORA-28: abandonment of opiodr treat unknown ospid (18707_1)

    I tried to use set linesize and column format also. but the output is not displayed in a row

    No idea what I have to put

    Kai

    Check the sys. X definition DBGALERTEXT $. MESSAGE_TEXT is VARCHAR2 (2048). So you need to see it on a single line using LINESIZE:

    SQL> select DISTINCT ORIGINATING_TIMESTAMP,MESSAGE_TEXT from sys.X$DBGALERTEXT WHERE MESSAGE_TEXT LIKE 'ORA-%' or MESSAGE_TEXT LIKE '%Fatal%' AND ORIGINATING_TIMESTAMP > SYSDATE-4;
    
    ORIGINATING_TIMESTAMP
    ---------------------------------------------------------------------------
    MESSAGE_TEXT
    --------------------------------------------------------------------------------
    26-JUL-10 11.52.01.178 AM -04:00
    ORA-1109 signalled during: ALTER DATABASE CLOSE NORMAL...
    
    SQL> set linesize 2200
    SQL> /
    
    ORIGINATING_TIMESTAMP                                                       MESSAGE_TEXT
    --------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------
    26-JUL-10 11.52.01.178 AM -04:00                                            ORA-1109 signalled during: ALTER DATABASE CLOSE NORMAL...
    
    SQL> 
    

    SY.

  • Import specifications of centralized in Sqlplus scripts possible column format?

    I want to centralise the definitions of column as

    FORMAT of COLUMN TABLE_NAME A20 direction "foobar".
    ...

    keep in a centralized definition file and import into several Sqlplus scripts (executing).

    Is - it somehow possible?

    Peter

    Is - it somehow possible?

    Yes put all definitions of column in a single file, you say coldef.sql

    Whenever you need to use it in a script that is run with the help

    Start coldef.sql

    Max
    http://oracleitalia.WordPress.com

  • Csv output SQLCL differs from output csv SQLPLUS

    Hello

    I try to replace my script sqlplus generating a csv file.

    with a new one generated by sqlcl because sqlcl seem to handle it "natively".

    However, I have several problems, it's not so easy... (it is not possible, in fact, as a replacement for sqlplus by sqlcl to generate a csv file)

    There are several differences with the release made with my script in sqlplus. Let me explain

    NB: Please note I'm french therefore:

    * default csv separator is; (but I could accept this separator is)

    * decimal separator is ",".

    Script from SQLplus

    trigger the echo

    Set feedback off

    fixed term off

    set point

    Go head

    the Embedded value on

    set pagesize 0

    break off Set

    NEWP NONE Set

    set SPACE 0

    TAB SET OFF

    recsep off Set

    left the underline

    COLUMN of resource_type FORMAT A10 COLUMN TYPEE

    ALTER session set nls_date_format = "dd/mm/yyyy";

    ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ",";

    set LINESIZE 30000

    Set trimspool on

    Coil test.csv

    SELECT "'sysdate';'" COL1 "; "" COL2 "; "" LENGTH "' double.

    SELECT

    '"' || SYSDATE | « « ; » »

    '"' || trunc (sysdate) | « « ; » »

    || To_char (sysdate, ' DD/MM/YYYY HH24:MI:SS'). « « ; » »

    || RM. LENGTH | '"'

    Of

    TABLE RM

    WHERE

    RM. CODE = "ABCD";

    spool off

    output

    SQLCL script

    trigger the echo

    Set feedback off

    fixed term off

    set point

    break off Set

    Set trimspool on

    Set sqlformat csv

    Coil test2.csv

    SELECT

    SYSDATE,

    trunc (sysdate),

    To_char (sysdate, ' DD/MM/YYYY HH24:MI:SS'),

    RM. LENGTH

    Of

    TABLE RM

    WHERE

    RM. COL = 'ABCD '.

    ;

    spool off

    output

    SQLplus output CSV (and the result is correct)

    "sysdate"; "' COL1 '; "" COL2 "; "" LENGTH ".

    "11/05/2015"; 11/05/2015; "11/05/2015-11:11:27 '; "6.07"

    SQLCL CSV output

    < blank line >

    "SYSDATE", "TRUNC (SYSDATE)", "TO_CHAR (SYSDATE," DD/MM/YYYY HH24:MI:SS) ',' LENGTH' "

    05/11/15 11:12:12, 000000000, 05/11/15 00:00:00000000000, ' 11/05/2015 11:12:12 ', 6,07

    --------

    You can see in the output of SQL CL

    * an empty line first (?)

    * the fields sysdate is followed, 0000000, which breaks the structure of the csv file. Don't know why this is displayed.

    * value sysdate is fine (date + hour) in sqlcl, trunc (sysdate) should not display the time (minor)

    * in sqlplus then I've not used instructions ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ",".

    digital data are 6.07 (whereas it should be 6.07, and default sqlplus output. (In sqlplus to 6.07, I need to put the NLS_NUMERIC statement above))

    * in sqlplus, only char data are placed in square brackets. In my case it would be necessary to have each data attached to make sure that imposing CSV is safe.

    If too many problems, I can't currently use sqlcl to generate a csv result...

    Don (don't know if this is the place to talk about SQL imporvement, , but it would be great if the sqlcl could be improved: )

    * the date of issue (000000) would be fixed (unless there is a solution?)

    * Digital output default must be with '.'. And after having the opportunity to change the decimal separator, as in SQLPLUS

    * We wouldn't abilty to choose whether the data should be included or not in the media (even for digital data / date)

    * We would be able to change the csv separator

    * no first blank line ould generated (minor)

    Thanks for any suggestions you could provide, because at the moment, I can't use sqlcl to the output in csv format, although it has very promising output features

    > We are working on support for that now.

    What I wanted, it was, it does not work in the latest version available, but work soon.

  • NLS_DATE_FORMAT in PLSQL Developer differ from sqlplus

    Hello

    When you set the nls_date_format sqlplus at the session level, the results are as expected.Capture.JPG

    Whereas, when you set the second level nls_date_format in PL/SQl developer, output the same format in both cases.

    Capture1.JPG

    help kindly on even...

    Thank you to make clear... just ask out of curiosity, is possible for my session I modified my NLS_DATE_FORMAT and always the system reflecting the NLS_DATE_FORMAT substituted by the client software...

    Means for my session how is it possible that without good privileges Client software replaces the format...

    Why do you think that the output that you see in a GUI such as PLSQL Developer is determined by NLS session parameters? When the result set contains a date, then the proponent of the product is free to decide if it is displayed after the session or some settings settings in the tool preferences.

    SELECT SYSDATE FROM dual;

    ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD ";

    SELECT SYSDATE FROM dual;

    When I run the present into a toad, I get two different formats for the last statement in the manner which I run it:

    F9 (run the statement): 10:26:08 09/01/2015

    F5 (Exceute as a script): 2015-09-01

    If the toad ignores the parameter when the developer thought that I don't know what I really want.

    The same executions in SQL Developer shows 2015-09-01 both times. Here, the designer would think "Hey the user is a developer, that he or she will know what to do" or the designer has not thought to the problem and simply used the session settings.

    Concerning

    Marcus

  • Get the domain FULL of SQLPLUS connect_identifier

    Hello!  I'm all new to Oracle.  I have a previous developer files that contain SQLPLUS commands.  I noticed that the format of the CONNECT subcommand is:

    username/password[@connect_identifier]

    I have something like:

    SQLPLUS foo/bar@fum

    What should I do to solve the 'MED' connect_identifier to a fully qualified domain name?

    Look in your tnsnames.ora file, or do a 'WUF tnsping"("fum"seems to be your login).

  • Export to HTML format with text "preformatted"?

    Hello

    I have a column varchar2 with contains carriage returns.  I want to run my query in SQL Developer and 'export' the results in HTML format.  But when I do, the data in the column lost things like several spaces and returns the cart.  That's why I want to mainly export the column with the < PRE >... < / PRE > html tags.  Any way to do this from SQL Developer?

    Example of table in sqlplus:

    SQL> create table my_demo (MY_TEXT varchar2(255));
    
    Table created.
    
    SQL> insert into my_demo values ('Hello'||CHR(10)||'   World');
    
    1 row created.
    
    SQL> select * from my_demo;
    
    MY_TEXT
    -----------------------------------------------------------------
    Hello
       World
    
    
    SQL> 
    

    So what I want is the MY_TEXT column in the HTML export file to show the world "Hello" above indented it word 'World', just like we see in SQLPlus (my actual query is obviously much more complex).  If I try to select the column with string literals '< PRE >' and ' < / PRE > ' around the column MY_TEXT it does not work and indicates those string and not as HTML tags.

    In SQL, we can use "COLUMN".... ENTMAP OFF"- but who does not work in SQL Developer.  Similarly, I don't see how the / * fixed * / index of the SQL Developer will help me.

    Suggestions?  An option may be missing me?

    Thank you.

    I suppose the best solution that I could do was modify the query for:

    Select '

    '||my_text||'
    "from my_demo;

    Then export it to HTML format.  Then open it with my favorite text editor and make the following replacements:

    < PRE >--->

    </PRE>    --->   

    Save my raw HTML code after manually making the substitution with the text editor and now I have the registered page displays properly as I want it.

    While work work - around, I was just hoping that there was a better solution that does not need me manually change the HTML in a text editor.

  • How to get sqlplus not to use the output of size documents fixed?

    I want to generate the sql code to clear all data in tables in the database of flat files, one file per table, one row per record.  I thought I'd try to use the ascii code for characters inherited 31 as a delimiter to separate the fields and start sqlplus. But a problem is how do you get to specify linesize? Are there not a way to get out of creating fixed size records in sqlplus? I would prefer each line to just be so great that it must be rather than set the linesize being the absolute maximum. (32767) or understand what the maximum size is on a per-table basis.

    Is it possible to do?

    What I've tried so far (so I would have executed him each resulting sort script d30_x.) OK but how to get rid of this thing linesize?

    / * create dump file using US 31 to separate the fields * /.

    wrap off Set

    Set linesize

    Set feedback off

    set pagesize 0

    set verify off

    UNDEF tab;

    set myfile = d30_ & & tab... SQL;

    is prompt myfile and myfile;

    coil & myfile

    Guest set linesize 2500

    Guest set pagesize 0

    Guest departed wrap

    quick game check out

    Quick spool & tab... LST

    Select guest of

    Select lower (column_name) |' | Chr (31)

    ||'
    of user_tab_columns
    where table_name = upper ('& tab') and
    column_id! = (select max (column_id) in the user_tab_columns where)
    table_name = upper ('& tab'))
    order of column_id
    /
    Select lower (column_name)
    of user_tab_columns
    where table_name = upper ('& tab') and
    column_id = (select max (column_id) in the user_tab_columns where)
    table_name = upper ('& tab'))
    order of column_id
    /
    from guest & tab
    Guest /.

    prompt off spool
    spool off

    Wait, I think it works!  Tell him to use the maximum linesize, then

    tell him to get rid of these spaces.

    OOPS I forgot something. A problem with this is that if there are embedded newlines \r \n one of those or both in a field, then this format that uses the newline to indicate the end of the recording is toast. And I know that they are inclined to do this. (Users can not live with them, can't live without 'em). More on that later.

    / * create dump file using US 31 to separate the fields * /.
    wrap off Set
    Set feedback off

    set linesize 150
    set pagesize 0
    set verify off

    UNDEF tab;

    set myfile = d30_ & tab... SQL;
    prompt myfile is &myfile;

    coil & myfile
    Guest set pagesize 0
    Guest departed wrap
    quick game check out
    prompt value trimspool on
    Guest trimout value on
    Guest set linesize 32767
    fast coil & tab... LST

    Select guest of
    Select lower (column_name) |' | Chr (31) | »
    of user_tab_columns
    where table_name = upper ('& tab') and
    column_id! = (select max (column_id) in the user_tab_columns where)
    table_name = upper ('& tab'))
    order of column_id
    /
    Select lower (column_name)
    of user_tab_columns
    where table_name = upper ('& tab') and
    column_id = (select max (column_id) in the user_tab_columns where)
    table_name = upper ('& tab'))
    order of column_id
    /
    Guest of & tab
    Guest /.

    prompt off spool
    spool off

    Post edited by: Lake

  • number format

    Hello

    on 10.2.0.4

    I treid the suite, but not an explicit display of

    SQL > select file #, status, checkpoint_change # from v$ datafile, whose name like '% SYS % ';

    STATUS # CHECKPOINT_CHANGE #.

    ---------- ------- ------------------

    1 1.9475E + 12 SYSTEM

    3. RECOVER 1.9475E + 12

    17 RETRIEVE 1.9475E + 12

    18 RETRIEVE 1.9475E + 12

    SQL > select file #, status, TO_CHAR (checkpoint_change #, '$99 990,99') v $ datafile where name like '%sys% ';

    STATUS # TO_CHAR (CHE

    ---------- ------- -----------

    1 SYSTEM #.

    RECOVER 3 #.

    RECOVER 17 #.

    RECOVER 18 #.

    SQL > select file #, status, TO_CHAR (checkpoint_change #, '99999990.000') of v$ datafile whose name like '% SYS % ';

    FOLDER # TO_CHAR (CHECK STATUS

    ---------- ------- -------------

    1 SYSTEM #.

    RECOVER 3 #.

    RECOVER 17 #.

    RECOVER 18 #.

    SQL > select file #, status, TO_CHAR (checkpoint_change #, '9999,9990.000') of v$ datafile whose name like '% SYS % ';

    FOLDER # TO_CHAR (HOSTING STATUS

    ---------- ------- --------------

    1 SYSTEM #.

    RECOVER 3 #.

    RECOVER 17 #.

    Can you help me please?

    Thank you.

    Checkpoint_change # is probably a number with more digits that you specified in the format.  You must specify a larger format (more numbers). Note: There is zero decimals, so you don't need to specify decimals.

    In sqlplus, you can also generically set numwdith 'N NUMLARGEUR SET' - for example "SET NUMLARGEUR 32" to allow up to 32 digits digital display.  Then, you need not specify a format for the column.

    Hemant K Collette

  • sqlplus spool and keep widths of varchar, left

    I'm a newb sqlplus.  I have a definition of table similar to the following:

    ID VARCHAR2 (10)

    address VARCHAR (40)

    etc...

    I wish I could wrap the contents of the table, where the fields of maintain their width max varchar and concat together.  Thus, for example:

    ID: 0123456789

    address: this is an address of 40 char with spaces

    I want to the coil of the output of the table and make it look like:

    0123456789This is an address of 40 char with spaces

    What I get is:

    0123456789 it is an address of 40 char with spaces

    I played with trimspool, linesize, pagesize, but as in the example above: why is he to put spaces between the fields id and address?  It's data is loaded from a ctl, via sqlldr file, which uses positional notation to load the data.  Everything I want to do is to be able to export data (now filtered), in a text file, looking as it did when it was imported.

    Even justify it right out?

    Thanks for the help.  Hope it was not too complicated :-)

    Well, that the format information in a control sql loader file (s) so you don't have to code yourself to match this format.  Oracle can not magically to output in the same format, he was received... once it is in the tables, format information do not exist in the database.

Maybe you are looking for

  • Glitch Safari

    I get an error message when I try to connect to Outlook.com via Safari.  He said that my request has been routed too many times and try again later.  I have for more than a month without result.  I see the address flash progress bar a bunch of times

  • Titles of the image?

    Pictures has been updated to show the names of files as the titles of the image still? TT2

  • How can I assign a browser to a specific office in El Capitan?

    How can I assign a browser to a specific office in El Capitan?

  • can I increase my speed of wifi with settings

    Hello... I would like to know if I can increase my speed of wifi with adjustments on my computer, all parameters that would adjust my speed with my adapter BT MCard HP WLAN 802.11 b/g/n 1 x 1, thank you... customized HP ENVY Phoenix 245 810qe desktop

  • HP Pavilion 17 Notebook: Recommended backup services

    I would like a recommendation for a back up (Cloud Service). I read some reviews on some services, and there have been problems with some tΘlΘchargement backups. Someone out there have experiences with these services and give me some suggestions.