I have problem with Oracle 10g database headig format.
I have this code
COLUMN id HEADING "Rodné|číslo" FORMAT A10
COLUMN name HEADING "Meno" FORMAT A20
COLUMN surname HEADING "Priezvisko" FORMAT A20
--some select here
Column id is char(10) type, other columns are varchar2(30) type. Result is this
Rodné
číslo Meno Priezvisko
---------- -------------------- --------------------
7951051548 Bohdana Filcova
4054207561 Bohumila Kmecova
As you can see header "Meno" interferes to first column and header "Priezvisko" interferes to second. I can't understand why. How can I solve this issue?
This seems to be a character set issue. SQL*Plus supports globalisation, so perhaps one of the characters you're using isn't in your session's characterset. If I set my NLS_LANG:
export NLS_LANG="ENGLISH_UNITED KINGDOM.WE8ISO8859P1"
Rodné
číslo Meno Priezvisko
---------- -------------------- --------------------
7951051548 Bohdana Filcova
4054207561 Bohumila Kmecova
... then I get the same behaviour you do. (It's slightly modified, but not fixed by set tab off). If I change my session to UTF8 then it aligns properly:
export NLS_LANG="ENGLISH_UNITED KINGDOM.UTF8"
Rodné
číslo Meno Priezvisko
---------- -------------------- --------------------
7951051548 Bohdana Filcova
4054207561 Bohumila Kmecova
This is in 11gR2, incidentally, so it isn't an Oracle 10g issue; my database character set is AL32UTF8. Also interesting is taking a dump of the value in each session, with 'select dump('Rodné|číslo', 1016) from dual'; with WE8ISO8859P1:
DUMP('RODNé|číSLO',1016)
--------------------------------------------------------------------------------
Typ=96 Len=20 CharacterSet=AL32UTF8: 52,6f,64,6e,c3,83,c2,a9,7c,c3,84,c2,8d,c3,8
3,c2,ad,73,6c,6f
... and with UTF8:
DUMP('RODNÉ|ČÍSLO',1016)
--------------------------------------------------------------------------------
Typ=96 Len=14 CharacterSet=AL32UTF8: 52,6f,64,6e,c3,a9,7c,c4,8d,c3,ad,73,6c,6f
Presumably with the former it thinks the output is taking up a bit more space than it actually is, so it isn't padding the heading quite right.
The č seems to be the problem. It is defined in Unicode, but not in WE8ISO8859P1 or WE8MSWIN1252 (sourced from here). In the Unicode version that's shown in the dump as c4,8d, and for the non-unicode it's building it from c3,84,c2,8d. Quite how and why that causes the effect you see is going beyond my understanding of character sets...
Related
I selected every details customers tables in the Order Entry Schema but my data isn't ordered. How do i make the table presentable making every column and row clear to read and understand
I used the query select * from oe.customers and below is how my data was retrieved and makes it quite difficult to read.
CUSTOMER_ID CUST_FIRST_NAME CUST_LAST_NAME
----------- -------------------- --------------------
CUST_ADDRESS(STREET_ADDRESS, POSTAL_CODE, CITY, STATE_PROVINCE, COUNTRY_ID)
--------------------------------------------------------------------------------
PHONE_NUMBERS
--------------------------------------------------------------------------------
NLS NLS_TERRITORY CREDIT_LIMIT
--- ------------------------------ ------------
CUST_EMAIL ACCOUNT_MGR_ID
---------------------------------------- --------------
CUST_GEO_LOCATION(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_OR
--------------------------------------------------------------------------------
DATE_OF_B MARITAL_STATUS G INCOME_LEVEL
--------- -------------------- - --------------------
25-MAY-44 single F A: Below 30,000
CUSTOMER_ID CUST_FIRST_NAME CUST_LAST_NAME
----------- -------------------- --------------------
CUST_ADDRESS(STREET_ADDRESS, POSTAL_CODE, CITY, STATE_PROVINCE, COUNTRY_ID)
--------------------------------------------------------------------------------
PHONE_NUMBERS
--------------------------------------------------------------------------------
NLS NLS_TERRITORY CREDIT_LIMIT
--- ------------------------------ ------------
CUST_EMAIL ACCOUNT_MGR_ID
---------------------------------------- --------------
CUST_GEO_LOCATION(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_OR
--------------------------------------------------------------------------------
DATE_OF_B MARITAL_STATUS G INCOME_LEVEL
--------- -------------------- - --------------------
Image showing the problem
First off, if you're just running ad hoc queries, you probably don't want to be using SQL*Plus. You're almost certainly better off downloading SQL Developer which is an actual GUI that presents query output in a nice, GUI fashion.
SQL*Plus was designed back in a time when reporting generally meant generating fixed width output that would get spooled to a physical printer every morning and generate hundreds of pages of output on green bar paper that would get distributed to various humans in the company to review. So you need to think like an old school report developer.
First, you need to figure out how wide your output window is and set your linesize appropriately. If your output window is, say, 120 characters wide, you'd start with
set linesize 120
Now, you have to figure out how much space out of those 120 character that you want to give each column of your output knowing that larger string values will wrap within the column. So if you want to allow 15 characters for the customer first and last name
column cust_first_name format a15;
column cust_last_name format a15;
You'd need to do that for each column you're outputting. Realistically, it probably doesn't make sense to select a geographic location from SQL*Plus, you'd want to select components of that composite object.
I am using SQL Developer v18.1 and the database version is Oracle 12c.
sql> select * from nls_database_parameters where parameter like 'NLS%CHARACTERSET';
PARAMETER VALUE
------------------------------ -------------------------
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_CHARACTERSET AL32UTF8
I would like to enter some non-ascii characters, such as 'í', but have no clue how to do that, even after some searches here and Google. Actually I am even unable to enter this example character here directly. I just copies it somewhere else and pasted in this question.
Thank you for the helps in advance!
Sam
How about this?
Here's a table which is supposed to contain some data.
SQL> create table test (col varchar2(20));
Table created.
Check ASCII code for the character you'd want to insert, by using the ASCII function:
SQL> select ascii('í') from dual;
ASCII('í')
----------
52103
OK; now we know its code so - insert it, but this time using the CHR function:
SQL> insert into test (col) values (chr(52103));
1 row created.
SQL> select * From test;
COL
--------------------
í
SQL>
I have queries that provide the output, but the output is really weird looking. It doesn't scroll over to look at the output, and the columns are really wide for things that are less than 20 characters. How do I get it to look normal? This is using Oracle SQL Developer. I searched online, but this doesn't seem to be what I need to do: format output archive. Although, I don't see how to get to the preference screen they are referring to either.
This is a portion of the output:
RAK SHEL SLT
---------- ---------- ------------------------------ PRT BRDBND_
---------------------------------------- ---------- DSLAM
-------------------------------------------------- VEND
-------------------------------------------------------------------------------- MODE
-------------------------------------------------------------------------------- PORT_ADDR CARRIER_ID
----------------- ----------------------------------------------------- CIRC_DE SERVICE SHELF_PT_NUM CARD_PART_NUM
---------- ---------- ------------------------- ------------------------- CARD_PT_DESC
-----------------------------------
3317 270812 1179G1 1170F1
As you can see, hopefully, it has really wide columns for the output, and column headers aren't at the top of the output window, it's in the output window. None of the output is more than 20 characters wide. I'm not sure why it's displaying that way.
Update: Plus, it's printing the column headers in the output window over and over again.
Try adding this line at the beginning of your script. It appears that your SQL Developer settings are what is making this output unreadable.
NOTE: I am using SQL Developer version 18.1.0.095
Edit: Added command to suppress reprinting of headers (pagesize) to 80 lines.
set sqlformat ansiconsole;
set pagesize 80;
I have the following query.
insert into ORDER_INFO(ORDINF_PK,ORDINF_LGNDET_PK_FK,MEDIA_TYPE,ORDINF_MUSIC_FK,DAT)
values (1,1,'Music',21,TO_DATE('14-OCT-2015','DD-MON-YYYY'));
insert into ORDER_INFO(ORDINF_PK,ORDINF_LGNDET_PK_FK,MEDIA_TYPE,ORDINF_MUSIC_FK,ORDINF_SERIES_FK,DAT)
values (2,2,'Series',71,23,TO_DATE('07-NOV-2015','DD-MON-YYYY'));
however when I do:
select * from ORDER_INFO;
I get:
truncating (as requested) before column ORDINF_SERIES_FK
truncating (as requested) before column ORDINF_MOVIES_FK
ORDINF_PK ORDINF_LGNDET_PK_FK MEDIA_TYPE ORDINF_MUSIC_FK DAT
---------- ------------------- -------------------- --------------- ---------
1 1 Music 21 14-NOV-14
2 2 Series 71 07-NOV-15
I understand that it is truncating ORDINF_MOVIES_FK because there is no entry in that column, but why is it truncating the column ORDINF_SERIES_FK?
I managed to solve the issue, I did this.
set wrap on;
set pagesize 50000;
set linesize 120;
link here: http://www.anattatechnologies.com/q/2012/01/sqlplus-pagesize-and-linesize/
Pay attention - both rows inserted and ARE in the database, so INSERT succeeded.
The warning you get is a warning from SQLPlus program that means that column is display not with full width (maybe the definition of column is long and SQLPlus decides to show column shorter because data you have in there is short).
You do not need to worry about this in any case.
See this link for more explanation about SQL*Plus wrap.
Just type col in sqlplus returns a list of columns, there are some columns ended with _recyc, where those columns are used ? I googled but could not find any documentation on them.
COLUMN droptime_plus_show_recyc ON
HEADING 'DROP TIME'
FORMAT a19
COLUMN objtype_plus_show_recyc ON
HEADING 'OBJECT TYPE'
FORMAT a12
COLUMN objectname_plus_show_recyc ON
HEADING 'RECYCLEBIN NAME'
FORMAT a30
COLUMN origname_plus_show_recyc ON
HEADING 'ORIGINAL NAME'
FORMAT a16
They're used by the show recyclebin command. If you run that you get headings like:
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
...
If you do clear columns and run it again you get:
ORIGNAME_PLUS_SHOW_RECYC OBJECTNAME_PLUS_SHOW_RECYC OBJTYPE_PLUS_SHOW_RECYC DROPTIME_PLUS_SHOW_
-------------------------------- ------------------------------ ------------------------- -------------------
...
Whatever underlying query show recyclebin is using (some variant of select .. from user_recyclebin presumably) is aliasing the columns in the resultset; SQL*Plus is configured to format those aliased names.
The other pre-set column definitions are similar; for example, show edition gives a column displayed with heading EDITION, but if you clear columns it reverts to the underlying NAME_COL_PLUS_SHOW_EDITION. Anything with _PLUS_SHOW_ is going to be for some output from a show command.