How can I reduce the width of column in Oracle (SQL Plus) with TIMESTAMP datatype? -
in sql plus output taking more space needs , i'd reduce 50 chars 20.
if reduce width 20 won't wide enough default timestamp or timestamp time zone format. when happens, sqlplus wrap value.
assume table b has timestamp column ts:
column ts format a20 select ts b; ts -------------------- 25-apr-13 11.28.40.1 50000 to cut down width further, decide information want , format accordingly. oracle datetime , timestamp formatting codes listed here.
note sqlplus won't let specify date format column statement. that's why used format a20 above. can 19 characters if drop fractional seconds , use 24-hour clock instead of am/pm, , drop time zone:
column tsformatted format a20 select to_char(ts, 'mm/dd/yyyy hh24:mi:ss') tsformatted b; tsformatted -------------------- 04/25/2013 11:28:40 if you're willing drop century can 2 of fractional seconds , exact width of 20:
column tsformatted format a20 select to_char(ts, 'mm/dd/yy hh24:mi:ss.ff2') tsformatted b; tsformatted -------------------- 04/25/13 11:28:40.15 finally, if want of timestamps automatically formatted in way, use alter session:
alter session set nls_timestamp_format = 'mm/dd/yy hh24:mi:ss.ff2'; column ts format a20 select ts b; -- don't need to_char because of default format ts -------------------- 04/25/13 11:28:40.15