Concept: CHAR Type: Setting the length string, n bytes long, if the length is not specified, the default is one byte length (one Chinese character is 2 bytes) VARCHAR2 type: the growing string, specify the specified definition Maximum length n, this type of data can be digitized, letters, and ASCII code character set (or EBCDIC)
All symbols in the character set standards accepted by the database system). If the data length does not reach the maximum value n, Oracle 8i automatically adjusts the field length according to the data size.
If you have spaces before and after your data, Oracle 8i will automatically delete it. VARCHAR2 is the most common data type. The maximum length of the index can be made 3209.
Happening:
When using the varchar2 type, it is found that in the setting field unique constraint is the purpose of achieving constraints. After careful study, the VARCHAR2 field matches the data.
There is a case where the end of the end is present.
analysis:
SQL> CREATE TABLE TEST2 (a char (6));
The table has been created.
SQL> INSERT INTO TEST2 VALUES ('ABC');
It has created a row.
SQL> INSERT INTO TEST2 VALUES ('BCD');
It has created a row.
SQL> SELECT * from test2 where a = 'bcd';
A ------ BCD
1 line has been selected.
SQL> SELECT * from test2 where a = 'bcd';
A ------ BCD
1 line has been selected.
SQL> ALTER TABLE TEST2 MODIFY (a varchar2 (6)) table has been changed.
SQL> SELECT * from test2 where a = 'bcd';
Unselected
SQL> SELECT * from test2 where a = 'bcd'
Unselected
SQL> SELECT * from test2 where a = 'bcd'
A ------ BCD
SQL> ALTER TABLE TEST2 MODIFY (a char (6));
The table has been changed.
SQL> SELECT * from test2 where a = 'bcd';
A ------ BCD
1 line has been selected.
SQL> ALTER TABLE TEST2 MODIFY (a char (6));
The table has been changed.
SQL> SELECT * from test2 where a = 'bcd';
A ------ BCD
1 line has been selected.
Conclusion: After the CHAR data type is changed to the VARCHAR2 type, Oracle will automatically add the end of the space to the field length; VARCHAR2 type is converted to a char type, oralce will automatically remove spaces at the end of the data.