Data types trong Oracle

Để tối ưu trong việc lưu trữ thì Oracle phân chia dữ liệu thành nhiều loại khác nhau, mỗi loại sẽ có đồ dài nhất định và phù hợp với từng trường hợp. Chúng ta có các nhóm chính như: character, numeric, date/time, LOB and rowid datatypes.

Vì dịch ra tiếng Việt sẽ dài dòng và khó hiểu nên mình giữ nguyên tiếng Anh nhé.

1. Character Datatypes

Character Datatypes hay còn gọi là kiểu dữ liệu kí tự, nó là kiểu chuỗi và mỗi kiểu sẽ có độ dài khác nhau.

Data Type Syntax Explanation
char(size) Where size is the number of characters to store. Fixed-length strings. Space padded.
nchar(size) Where size is the number of characters to store. Fixed-length NLS string Space padded.
nvarchar2(size) Where size is the number of characters to store. Variable-length NLS string.
varchar2(size) Where size is the number of characters to store. Variable-length string.
long Variable-length strings. (backward compatible)
raw Variable-length binary strings
long raw Variable-length binary strings. (backward compatible)

2. Numeric Datatypes

Data Type Syntax Explanation
number(p,s)

Where p is the precision and s is the scale.

For example, number(7,2) is a number that has 5 digits before the decimal and 2 digits after the decimal.

numeric(p,s)

Where p is the precision and s is the scale.

For example, numeric(7,2) is a number that has 5 digits before the decimal and 2 digits after the decimal.

float  
dec(p,s)

Where p is the precision and s is the scale.

For example, dec(3,1) is a number that has 2 digits before the decimal and 1 digit after the decimal.

decimal(p,s)

Where p is the precision and s is the scale.

For example, decimal(3,1) is a number that has 2 digits before the decimal and 1 digit after the decimal.

integer  
int  
smallint  
real  
double precision  

3. Date/Time Datatypes

Data Type Syntax Explanation
date  
timestamp (fractional seconds precision)

Includes year, month, day, hour, minute, and seconds.

For example:
timestamp(6)

timestamp (fractional seconds precision) with time zone

Includes year, month, day, hour, minute, and seconds; with a time zone displacement value.

For example:
timestamp(5) with time zone

timestamp (fractional seconds precision) with local time zone Includes year, month, day, hour, minute, and seconds; with a time zone expressed as the session time zone.

For example:
timestamp(4) with local time zone

interval year
(year precision)
to month

Time period stored in years and months.

For example:
interval year(4) to month

interval day
(day precision)
to second (fractional seconds precision)

Time period stored in days, hours, minutes, and seconds.

For example:
interval day(2) to second(6)

4. Large Object (LOB) Datatypes

Data Type Syntax Explanation
bfile File locators that point to a binary file on the server file system (outside the database).
blob Stores unstructured binary large objects.
clob Stores single-byte and multi-byte character data.
nclob Stores unicode data.

5. Rowid Datatypes

Data Type Syntax Explanation
rowid Fixed-length binary data. Every record in the database has a physical address or rowid.
urowid(size)

Universal rowid.

Where size is optional.

Trên là danh sách các kiểu dữ liệu trong Oracle, mình cũng không muốn dịch ra tiếng việt vì dài dòng lắm, bạn tự tham khảo nhé.

-------------------#####-------------------

Lưu ý: bài viết có tham khảo hoặc dịch lại từ http://javatpoint.com.

Nguồn: freetuts.net