The Oracle data discusses char, varchar, VARCHAR2 data types:
These three types are the most we use, in the database we how to use it?
The length of 1.CHAR is fixed, with a maximum of 2000 strings:
2.VARCHAR, VARCHAR2 can be sure that the Carchar data type is currently available in Oracle:
Their differences on the internet for a long while there is no accurate answer, said that the Oracle varchar is VARCHAR2 synonyms, also known as aliases.
Second, it is assumed that varchar is a variable string with a maximum length of 2000 (consistent with varchar in SQL Server), while the maximum length of VARCHAR2 is 4000.
Knowing their characteristics, we'll discuss the difference:
char, varchar, varchar2 since the latter two are not very different, let's discuss the difference between Char and their use first.
The latter both save space compared to char and are slightly less efficient than char. If you want to be efficient, you have to sacrifice space. This is what we often call "space-for-efficiency" in database design. Although the latter two save space than Char, but if the varchar and VARCHAR2 columns are often modified, and each time the length of the modified data is different, this causes the "row migration" phenomenon (row migration), which causes the redundant I/O, is the database set up and tuning to avoid as far as possible, In this case it would be better to use char instead of varchar and VARCHAR2. There is, of course, a case where a field with almost constant length, such as an identity card, can be considered with char for greater efficiency.
varchar and varchar2 here to the point, the difference between us in SQL Server we have a basic understanding, we may all know, at most, is the review, but Oracle has added a VARCHAR2 type, is not used by people before. Because Oracle guarantees that the data type is up and backward-compatible in any version, it does not guarantee varchar, and there are other data types that have varchar in general:
Do not use varchar if you want to be compatible with Oracle's new version of the database, and do not use VARCHAR2 if you want to be compatible with databases other than Oracle.
|
Data type |
Parameters |
Describe |
|
CHAR (n) |
N=1 to 2000 bytes |
Fixed length string, n bytes long, if not specified length, default is 1 bytes long (one kanji is 2 bytes) |
|
VARCHAR2 (N) |
N=1 to 4000 bytes |
Variable-length string, specifying the maximum length of n when defined,
This data type can be used for all symbols in numbers, letters, and ASCII character sets (or the standard set of character sets accepted by database systems such as EBCDIC).
If the data length does not reach the maximum n,oracle 8i automatically adjusts the field length based on the data size,
If you have a space before and after your data, Oracle 8i will automatically delete it. VARCHAR2 is the most commonly used data type.
The maximum length of the index can be 3209. |
|
Number (M,n) |
M=1 to 38
n=-84 to 127 |
A variable-length numeric column that allows 0, positive, and negative values, and M is the number of digits of all valid digits, and n is the number of digits after the decimal point.
For example: Number (5,2), the maximum value for this field is 99,999, and if the value exceeds the number of digits, the extra digits are truncated.
such as number (5,2), but enter 575.316 in this field in a row of data, the value that is actually saved to the field is 575.32.
For example: Number (3,0), enter 575.316, the actual data saved is 575. |
|
Date |
No |
All legal dates from January 1, 4712 BC to December 31, 4712 A.D.,
Oracle 8i actually saves date data internally by 7 bytes, including hours, minutes, and seconds in the definition.
The default format is Dd-mon-yy, such as July-November-00 for November 7, 2000. |
|
Long |
No |
Variable long character column with a maximum length limit of 2GB for long strings of data that do not need to be searched for strings, and the varchar2 type for character searches.
Long is an older type of data that will gradually be replaced by large object data types such as BLOBs, CLOB, NCLOB, and so on. |
|
Raw (N) |
N=1 to 2000 |
Variable-length binary data, which must indicate the maximum length n,oracle 8i in this format to save smaller graphic files or formatted text files, such as Miceosoft Word documents, when specifying fields.
Raw is an older type of data that will gradually be replaced by large object data types such as BLOBs, CLOB, NCLOB, and so on. |
|
Long Raw |
No |
Variable long binary data with a maximum length of 2GB. Oracle 8i uses this format to save large graphic files or formatted text files, such as Miceosoft Word documents, as well as non-text files such as audio and video.
You cannot have both long and long raw types in the same table, and long Raw is an older data type that will gradually be replaced by large object data types such as BLOBs, CLOB, NCLOB, and so on. |
|
Blob
Clob
Nclob |
No |
Three large objects (lobs) for storing large graphic files or formatted text files, such as Miceosoft Word documents, and non-text files such as audio and video, with a maximum length of 4GB.
There are several types of lobs, depending on the type of bytes you use, Oracle 8i actually stores the data inside the database.
You can perform special operations such as read, store, write, and so on. |
|
bfile |
No |
A large binary object file saved outside the database with a maximum length of 4GB.
This external LOB type, which records changes through the database, but the data is kept in a specific place outside the database.
Oracle 8i can read, query bfile, but cannot write.
The size is determined by the operating system. |
|
Oracle basic data Type "under"