What is the major difference between Varchar2 and char

前端 未结 7 758
独厮守ぢ
独厮守ぢ 2020-11-22 14:33

Creating Table:

CREATE TABLE test (
charcol    CHAR(10),
varcharcol VARCHAR2(10));

SELECT LENGTH(charcol), LENGTH(varcharcol) FROM test;
         


        
7条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 15:05

    When stored in a database, varchar2 uses only the allocated space. E.g. if you have a varchar2(1999) and put 50 bytes in the table, it will use 52 bytes.

    But when stored in a database, char always uses the maximum length and is blank-padded. E.g. if you have char(1999) and put 50 bytes in the table, it will consume 2000 bytes.

提交回复
热议问题