There are many common data types in Oracle database, including numeric type, character type, date type, etc. Some common data types will be introduced in detail below, with corresponding code examples.
- Numerical data type:
- NUMBER: Used to store numeric type data, and the precision and range can be specified as needed.
Example: CREATE TABLE test_table (
id NUMBER(10),
salary NUMBER(8,2)
);
- INTEGER: used for storage Integer type data.
Example: CREATE TABLE test_table (
id INTEGER,
age INTEGER
);
- Character data type:
- VARCHAR2: Used to store variable-length character data, with a maximum length of 4000 bytes.
Example: CREATE TABLE test_table (
name VARCHAR2(50),
address VARCHAR2(100)
);
- CHAR: used to store fixed length Character data, the missing part will be filled with spaces.
Example: CREATE TABLE test_table (
code CHAR(5),
status CHAR(10)
);
- Date data type:
- DATE: Used to store date and time data.
Example: CREATE TABLE test_table (
hire_date DATE,
birth_date DATE
);
##TIMESTAMP: used to store date, time and time zone information. - Example: CREATE TABLE test_table (
order_time TIMESTAMP,
delivery_time TIMESTAMP
);
Other common data types: - CLOB: Used to store large amounts of text data.
- Example: CREATE TABLE test_table (
description CLOB
);
BLOB: used to store large amounts of binary data. - Example: CREATE TABLE test_table (
image BLOB
);
The above are common data types and their code examples in Oracle database. Different data types are suitable for different For data storage requirements, you can choose the appropriate data type to create a database table according to the actual situation.
The above is the detailed content of What are the common data types in Oracle database?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn