1, char (size) holds a string, it can hold a maximum of 2000 characters, is a fixed length.
To illustrate:
CREATE table test1 (name char); The name field in the//test1 table holds a maximum of 32 characters and less than 32 characters Oracle will use a space to make up the error if it exceeds.
2, VARCHAR2 (size) to hold a string, it can hold the maximum 4,000 characters, is variable length.
To illustrate:
CREATE table Test2 (name varchar2); The Name field in the//test2 table holds a maximum of 16 characters, and the actual number of characters is the space of several characters, if the error is exceeded.
Special Note: If the length of our data is fixed, such as the product number (8-bit), you should use char to store it, as this will increase the speed of access. If the length of the stored data is variable, use VARCHAR2 to store it.
3, nchar (n) in Unicode encoding to hold the string, it can hold a maximum of 2000 characters, is a fixed length.
To illustrate:
CREATE TABLE TEST3 (name nchar (32));//similar to char, just storing strings in Unicode encoding
4, nvarchar (n) in Unicode encoding to hold the string, it can hold up to 4,000 characters, is variable length.
To illustrate:
CREATE TABLE Test4 (name Nvarchar2 (16));//similar to VARCHAR2, just storing strings in Unicode encoding
Special Note:the difference between nchar and nvarchar2 and Char and VARCHAR2 is that nchar and NVARCHAR2 are only 1 characters in either English characters or Chinese character. such as storing a and storing ' in ' are only 1 character bits. Char and VARCHAR2 store A as 1 characters and hold ' Medium ' for 2 characters.
5, CLOB character type large object, it can hold the maximum 8TB, is the variable length.
As with the char/varchar2/nchar/nvarchar2 of the character type .
6, Blob binary data, can be stored pictures, sound, it can store 8TB, is variable length.
As with the char/varchar2/nchar/nvarchar2 of the character type .
Note: In general, the database is rarely used to store media class files, generally only use the database to record the media class file The URL address. If you consider the security of your files, you can store them in a database.
7, number can be stored in integers, can also store decimals, is variable length.
Number (P,s)//p represents the integer digits, s represents the decimal digits
Save data range:-1.0e-130 to 1.0e+126; within the machine: 1~22bytes
Special Note:
valid bits: From left to right, the first non- 0 number is the first valid bit.
S>0 to the right of the decimal point s bit, and rounded. Then verify that the effective bit is <=p
S<0 to the left of the decimal point s bit, and rounded. Then verify that the effective bit is <=p+|s|
S=0 is equivalent to number (p) when number represents an integer.
Description:-1.0e-130 (scientific notation): that is-1.0 times 10-130 Times Square
1.0e+126: Is 1.0 times 10 of the 126-time Square
To illustrate:
Number (5,2)
represents a decimal number with 5 valid digits and 2 decimal places. Range -999.99~999.99
if the number exceeds the number of digits, the extra bits are truncated. But enter 575.316 in this field in a row of data, and the value that is actually saved to the field is 575.32.
Number (5) <=>number (5,0)
represents a five-bit integer, Range -99999~99999.
input 57523.316, the actual data saved is 57523
8, date, used to denote time, (year/month/day/hour/minute/second), is fixed length.
To illustrate:
CREATE table Test5 (birthday date), or//add to use the default format insert into TEST5 values (' November-November-11 '); If you use INSERT into TEST5 values (' 2011-11-11 ') error.
Special NOTE:The Oracle date has the default format: DD-MON-YYYY, day-month-year; if we want to use our own custom dates, we can, but we need to add them with Oracle functions.
Basic data types for getting started with Oracle