dbTalk Databases Forums  

Trailing spaces trimmed by default?

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Trailing spaces trimmed by default? in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tarby777
 
Posts: n/a

Default Trailing spaces trimmed by default? - 11-06-2006 , 03:13 AM






Hi all,

When doing either of these operations in 9i:

create table x as (select * from y);

insert into x(a,b,c) (select a,b,c from y);

....does Oracle trim trailing spaces from varchar2 columns by default
and if so, can it be over-ridden? I'm losing some trailing spaces from
my data during an upgrade and I suspect that one of these operations is
causing it but I've not been able to reproduce the problem in tests...

TIA
Tarby


Reply With Quote
  #2  
Old   
sybrandb
 
Posts: n/a

Default Re: Trailing spaces trimmed by default? - 11-06-2006 , 03:50 AM








On Nov 6, 10:13 am, "Tarby777" <nick_william... (AT) mentorg (DOT) com> wrote:
Quote:
Hi all,

When doing either of these operations in 9i:

create table x as (select * from y);

insert into x(a,b,c) (select a,b,c from y);

...does Oracle trim trailing spaces from varchar2 columns by default
and if so, can it be over-ridden? I'm losing some trailing spaces from
my data during an upgrade and I suspect that one of these operations is
causing it but I've not been able to reproduce the problem in tests...

TIA
Tarby


Reply With Quote
  #3  
Old   
sybrandb
 
Posts: n/a

Default Re: Trailing spaces trimmed by default? - 11-06-2006 , 03:53 AM





On Nov 6, 10:13 am, "Tarby777" <nick_william... (AT) mentorg (DOT) com> wrote:
Quote:
Hi all,

When doing either of these operations in 9i:

create table x as (select * from y);

insert into x(a,b,c) (select a,b,c from y);

...does Oracle trim trailing spaces from varchar2 columns by default
and if so, can it be over-ridden? I'm losing some trailing spaces from
my data during an upgrade and I suspect that one of these operations is
causing it but I've not been able to reproduce the problem in tests...

TIA
Tarby
Oracle does NOT trim trailing spaces.
It strikes me in your examples in both cases you are using an inline
view where you don't need to. The parentheses are redundant. Maybe they
are causing the problem.
Also '9i' is too inaccurate and doesn't tell anything.

--
Sybrand Bakker
Senior Oracle DBA



Reply With Quote
  #4  
Old   
Tarby777
 
Posts: n/a

Default Re: Trailing spaces trimmed by default? - 11-06-2006 , 06:12 AM



Thanks Sybrand,

I'll give it a whirl without the parentheses. BTW, it's 9.2.0.8.0.

Regards,
Tarby


Reply With Quote
  #5  
Old   
EscVector
 
Posts: n/a

Default Re: Trailing spaces trimmed by default? - 11-07-2006 , 10:36 AM




Tarby777 wrote:
Quote:
Hi all,

When doing either of these operations in 9i:

create table x as (select * from y);

insert into x(a,b,c) (select a,b,c from y);

...does Oracle trim trailing spaces from varchar2 columns by default
and if so, can it be over-ridden? I'm losing some trailing spaces from
my data during an upgrade and I suspect that one of these operations is
causing it but I've not been able to reproduce the problem in tests...

TIA
Tarby
Here's a test in 10g. Will also test in 9.2.0.7
No timming.
Also, in line view is when the FROM is a select.
The parens here make no difference...

11:32:05 SQL> create table test(col1 varchar2(10));

Table created.

Elapsed: 00:00:00.01
11:32:17 SQL> insert into test values (' ');

1 row created.

Elapsed: 00:00:00.00
11:32:34 SQL> select length(col1),col1 from test;

LENGTH(COL1) COL1
------------ ----------
10

Elapsed: 00:00:00.00
11:32:55 SQL> create table test2 as select * from test;

Table created.

Elapsed: 00:00:00.39
11:33:31 SQL> insert into test2 select * from test;

1 row created.

Elapsed: 00:00:00.00
11:33:46 SQL> select length(col1),col1 from test;

LENGTH(COL1) COL1
------------ ----------
10

Elapsed: 00:00:00.00
11:34:03 SQL> select length(col1),col1 from test2;

LENGTH(COL1) COL1
------------ ----------
10
10

Elapsed: 00:00:00.03
11:34:13 SQL> insert into test2 (select col1 from test);

1 row created.

Elapsed: 00:00:00.00
11:35:22 SQL> select length(col1),col1 from test2;

LENGTH(COL1) COL1
------------ ----------
10
10
10

Elapsed: 00:00:00.01
11:35:27 SQL>



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.