SQLPLUS Column Widths – Default Settings in Oracle 11g R2

oracleoracle-11g-r2sqlplus

For almost all my databases, when I run a SELECT statement, the length of the column displayed is sized to the width of the data being queried. However, I have two databases (Dev and Prod for the same application) that seem to default all column sizes to either 32 characters wide. If the data is wider than 32 characters or a column alias is used, it defaults the column to 128 characters wide.

Here are some examples from one of many good systems:

>select '1234567890' XX_Identifier from dual;

XX_IDENTIF
----------
1234567890

>select '12345678901234567890' XX_Identifier from dual;

XX_IDENTIFIER
--------------------
12345678901234567890

Here are some examples from one of the bad systems:

>select '1234567890' XX_Identifier from dual;

XX_IDENTIFIER
--------------------------------
1234567890

>select '12345678901234567890' XX_Identifier from dual;

XX_IDENTIFIER
--------------------------------
12345678901234567890

I've checked the sqlplus settings and they are all the same. I didn't see any database parameters that looked out of the ordinary and they both have identical NLS parameters. Both databases use the same character set.

I realize I could define a format for every column being queried, but this should not be necessary as it is not on any other DB.

The database having this problem is 11.2.0.1, while all our others are 11.2.0.4, so perhaps there is a bug that I haven't been able to find. The sqlplus client I am using is 12.1.0.1 in both cases.

Update:
The symptoms don't match exactly, but Doc ID 330717.1 talks about column widths in sqlplus and basically says you can't guarantee anything without setting the format. I can accept this, but since the behavior is consistent, it seems like a cause can be determined.

Best Answer

I found the issue. It is documented an oracle note (Doc ID 1086519.1). I used the first workaround listed which is to set CURSOR_SHARING to exact.

ALTER SESSION SET CURSOR_SHARING=EXACT;