Pages

Thursday, May 9, 2013


How to find a column has space:

There may be several other ways to find space in a column, this is another simple way

SQL> sho user
USER is "SYS"
SQL> conn a/a
Connected.
SQL> create table space (space varchar2(10));

Table created.

SQL> insert into space values ('test1');

1 row created.

SQL> insert into space values ('test2 ');

1 row created.

SQL> insert into space values ('test3  ');

1 row created.

SQL> insert into space values ('test4   ');

1 row created.

SQL> insert into space values ('test5    ');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from space;

SPACE
----------
test1
test2
test3
test4
test5

SQL> select length(space) from space;

LENGTH(SPACE)
-------------
            5
            6
            7
            8
            9

SQL> select space|| ';' from space;

SPACE||';'
-----------
test1;
test2 ;
test3  ;
test4   ;
test5    ;

SQL> select length(space) "length",space|| ';' value from space;

    length VALUE
---------- -----------
         5 test1;
         6 test2 ;
         7 test3  ;
         8 test4   ;
         9 test5    ;

No comments:

Post a Comment