In Oracle 9i, reading char fields is inconvenient, which limits the use of char fields. to read the value of a field, use the following methods:
SQL> Create Table Test (
2 a char (5 ))
3 tablespace users;
The table has been created.
SQL> insert into test values ('1 ');
One row has been created.
SQL> insert into test values ('2 ');
One row has been created.
SQL> insert into test values ('20140901 ');
One row has been created.
SQL> select * from test;
A
-----
1
2
12345
SQL> select * from test where trim (A) = '1 ';
A
-----
1
SQL> select * from test where a = '1 ';
A
-----
1
Before reading data, you must first remove spaces or consider spaces.
In Oracle 9i, the char field is optimized and can be read using the following methods:
SQL> select * from test where a = '1 ';
A
-----
1
This reading method is the same as reading a varhcar field. Therefore, when reading a field string, you do not need to consider the char or varchar type, at the same time, due to the efficiency advantage of char fields, char fields can be used for character fields with little length changes.
Finally:
SQL> truncate table test;
The table has been truncated.
SQL> drop table test;
The table is discarded.
SQL>