SQL,PL/SQL 数据类型一览表

简介: The following is a list of datatypes available in Oracle.Character DatatypesThe following are the Character Datatypes in Or...

The following is a list of datatypes available in Oracle.

Character Datatypes

The following are the Character Datatypes in Oracle:

Data Type Syntax

Oracle 9i

Oracle 10g

Oracle 11g

Explanation
(if applicable)

char(size)

Maximum size of 2000 bytes.

Maximum size of 2000 bytes.

Maximum size of 2000 bytes.

Where size is the number of characters to store. Fixed-length strings. Space padded.

nchar(size)

Maximum size of 2000 bytes.

Maximum size of 2000 bytes.

Maximum size of 2000 bytes.

Where size is the number of characters to store. Fixed-length NLS string Space padded.

nvarchar2(size)

Maximum size of 4000 bytes.

Maximum size of 4000 bytes.

Maximum size of 4000 bytes.

Where size is the number of characters to store. Variable-length NLS string.

varchar2(size)

Maximum size of 4000 bytes.

Maximum size of 4000 bytes.

Maximum size of 4000 bytes.

Where size is the number of characters to store. Variable-length string.

long

Maximum size of 2GB.

Maximum size of 2GB.

Maximum size of 2GB.

Variable-length strings. (backward compatible)

raw

Maximum size of 2000 bytes.

Maximum size of 2000 bytes.

Maximum size of 2000 bytes.

Variable-length binary strings

long raw

Maximum size of 2GB.

Maximum size of 2GB.

Maximum size of 2GB.

Variable-length binary strings. (backward compatible)

Numeric Datatypes

The following are the Numeric Datatypes in Oracle:

Data Type Syntax

Oracle 9i

Oracle 10g

Oracle 11g

Explanation
(if applicable)

number(p,s)

Precision can range from 1 to 38.
Scale can range from -84 to 127.

Precision can range from 1 to 38.
Scale can range from -84 to 127.

Precision can range from 1 to 38.
Scale can range from -84 to 127.

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)

Precision can range from 1 to 38.

Precision can range from 1 to 38.

Precision can range from 1 to 38.

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)

Precision can range from 1 to 38.

Precision can range from 1 to 38.

Precision can range from 1 to 38.

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)

Precision can range from 1 to 38.

Precision can range from 1 to 38.

Precision can range from 1 to 38.

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

 

 

 

 

Date/Time Datatypes

The following are the Date/Time Datatypes in Oracle:

Data Type Syntax

Oracle 9i

Oracle 10g

Oracle 11g

Explanation
(if applicable)

date

A date between Jan 1, 4712 BC and Dec 31, 9999 AD.

A date between Jan 1, 4712 BC and Dec 31, 9999 AD.

A date between Jan 1, 4712 BC and Dec 31, 9999 AD.

 

timestamp (fractional seconds precision)

fractional seconds precision must be a number between 0 and 9. (default is 6)

fractional seconds precision must be a number between 0 and 9. (default is 6)

fractional seconds precision must be a number between 0 and 9. (default is 6)

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

For example:
timestamp(6)

timestamp (fractional seconds precision) with time zone

fractional seconds precision must be a number between 0 and 9. (default is 6)

fractional seconds precision must be a number between 0 and 9. (default is 6)

fractional seconds precision must be a number between 0 and 9. (default is 6)

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

fractional seconds precision must be a number between 0 and 9. (default is 6)

fractional seconds precision must be a number between 0 and 9. (default is 6)

fractional seconds precision must be a number between 0 and 9. (default is 6)

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

year precision is the number of digits in the year. (default is 2)

year precision is the number of digits in the year. (default is 2)

year precision is the number of digits in the year. (default is 2)

Time period stored in years and months.

For example:
interval year(4) to month

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

day precision must be a number between 0 and 9. (default is 2)

fractional seconds precision must be a number between 0 and 9. (default is 6)

day precision must be a number between 0 and 9. (default is 2)

fractional seconds precision must be a number between 0 and 9. (default is 6)

day precision must be a number between 0 and 9. (default is 2)

fractional seconds precision must be a number between 0 and 9. (default is 6)

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

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

Large Object (LOB) Datatypes

The following are the LOB Datatypes in Oracle:

Data Type Syntax

Oracle 9i

Oracle 10g

Oracle 11g

Explanation
(if applicable)

bfile

Maximum file size of 4GB.

Maximum file size of 232-1 bytes.

Maximum file size of 264-1 bytes.

File locators that point to a binary file on the server file system (outside the database).

blob

Store up to 4GB of binary data.

Store up to (4 gigabytes -1) * (the value of the CHUNK parameter of LOB storage).

Store up to (4 gigabytes -1) * (the value of the CHUNK parameter of LOB storage).

Stores unstructured binary large objects.

clob

Store up to 4GB of character data.

Store up to (4 gigabytes -1) * (the value of the CHUNK parameter of LOB storage) of character data.

Store up to (4 gigabytes -1) * (the value of the CHUNK parameter of LOB storage) of character data.

Stores single-byte and multi-byte character data.

nclob

Store up to 4GB of character text data.

Store up to (4 gigabytes -1) * (the value of the CHUNK parameter of LOB storage) of character text data.

Store up to (4 gigabytes -1) * (the value of the CHUNK parameter of LOB storage) of character text data.

Stores unicode data.

Rowid Datatypes

The following are the Rowid Datatypes in Oracle:

Data Type Syntax

Oracle 9i

Oracle 10g

Oracle 11g

Explanation
(if applicable)

rowid

The format of the rowid is: BBBBBBB.RRRR.FFFFF

Where BBBBBBB is the block in the database file;
RRRR is the row in the block;
FFFFF is the database file.

The format of the rowid is: BBBBBBB.RRRR.FFFFF

Where BBBBBBB is the block in the database file;
RRRR is the row in the block;
FFFFF is the database file.

The format of the rowid is: BBBBBBB.RRRR.FFFFF

Where BBBBBBB is the block in the database file;
RRRR is the row in the block;
FFFFF is the database file.

Fixed-length binary data. Every record in the database has a physical address or rowid.

urowid(size)

 

 

 

Universal rowid.

Where size is optional

 更多参考:

DML Error Logging 特性 

PL/SQL --> 游标

PL/SQL --> 隐式游标(SQL%FOUND)

批量SQL之 FORALL 语句

批量SQL之 BULK COLLECT 子句

PL/SQL 集合的初始化与赋值

PL/SQL 联合数组与嵌套表
PL/SQL 变长数组
PL/SQL --> PL/SQL记录

SQL tuning 步骤

高效SQL语句必杀技

父游标、子游标及共享游标

绑定变量及其优缺点

dbms_xplan之display_cursor函数的使用

dbms_xplan之display函数的使用

执行计划中各字段各模块描述

使用 EXPLAIN PLAN 获取SQL语句执行计划

 

目录
相关文章
|
3月前
|
SQL 人工智能 JSON
Flink 2.1 SQL:解锁实时数据与AI集成,实现可扩展流处理
简介:本文整理自阿里云高级技术专家李麟在Flink Forward Asia 2025新加坡站的分享,介绍了Flink 2.1 SQL在实时数据处理与AI融合方面的关键进展,包括AI函数集成、Join优化及未来发展方向,助力构建高效实时AI管道。
787 43
|
3月前
|
SQL 人工智能 JSON
Flink 2.1 SQL:解锁实时数据与AI集成,实现可扩展流处理
本文整理自阿里云的高级技术专家、Apache Flink PMC 成员李麟老师在 Flink Forward Asia 2025 新加坡[1]站 —— 实时 AI 专场中的分享。将带来关于 Flink 2.1 版本中 SQL 在实时数据处理和 AI 方面进展的话题。
283 0
Flink 2.1 SQL:解锁实时数据与AI集成,实现可扩展流处理
|
4月前
|
SQL
SQL如何只让特定列中只显示一行数据
SQL如何只让特定列中只显示一行数据
|
8月前
|
SQL 自然语言处理 数据库
【Azure Developer】分享两段Python代码处理表格(CSV格式)数据 : 根据每列的内容生成SQL语句
本文介绍了使用Python Pandas处理数据收集任务中格式不统一的问题。针对两种情况:服务名对应多人拥有状态(1/0表示),以及服务名与人名重复列的情况,分别采用双层for循环和字典数据结构实现数据转换,最终生成Name对应的Services列表(逗号分隔)。此方法高效解决大量数据的人工处理难题,减少错误并提升效率。文中附带代码示例及执行结果截图,便于理解和实践。
226 4
|
4月前
|
SQL
SQL中如何删除指定查询出来的数据
SQL中如何删除指定查询出来的数据
|
4月前
|
SQL 关系型数据库 MySQL
SQL如何对不同表的数据进行更新
本文介绍了如何将表A的Col1数据更新到表B的Col1中,分别提供了Microsoft SQL和MySQL的实现方法,并探讨了多表合并后更新的优化方式,如使用MERGE语句提升效率。适用于数据库数据同步与批量更新场景。
|
6月前
|
SQL 数据挖掘 关系型数据库
【SQL 周周练】一千条数据需要做一天,怎么用 SQL 处理电表数据(如何动态构造自然月)
题目来自于某位发帖人在某 Excel 论坛的求助,他需要将电表缴费数据按照缴费区间拆开后再按月份汇总。当时用手工处理数据,自称一千条数据就需要处理一天。我将这个问题转化为 SQL 题目。
239 12
|
5月前
|
SQL DataWorks 数据管理
SQL血缘分析实战!数据人必会的3大救命场景
1. 开源工具:Apache Atlas(元数据管理)、Spline(血缘追踪) 2. 企业级方案:阿里DataWorks血缘分析、腾讯云CDW血缘引擎 3. 自研技巧:在ETL脚本中植入版本水印,用注释记录业务逻辑变更 📌 重点总结:
|
6月前
|
SQL 数据采集 资源调度
【SQL 周周练】爬取短视频发现数据缺失,如何用 SQL 填充
爬虫爬取抖音和快手的短视频数据时,如果遇到数据缺失的情况,如何使用 SQL 语句完成数据的补全。
167 5
|
9月前
|
SQL 关系型数据库 MySQL
基于SQL Server / MySQL进行百万条数据过滤优化方案
对百万级别数据进行高效过滤查询,需要综合使用索引、查询优化、表分区、统计信息和视图等技术手段。通过合理的数据库设计和查询优化,可以显著提升查询性能,确保系统的高效稳定运行。
430 9