技术标签: 数据库 python java mysql oracle
Every programming language has built-in data types which are used for declaring variables and many other related tasks. Variable is nothing but the name of the memory space. Every variable has a data type which specifies the storage format, set of specified values, range of the variable and many other such factors.
Variables have to be defined in the declaration section of a PL/SQL program. However, its not mandatory to include a declaration section and variable declaration in a PL/SQL program if its not required.
The Data Types used in PL/SQL are as follows:
|
|
| Image Source |
1. Scalar: These data types don’t include any internal components. It includes data types such as NUMBER, DATE, BOOLEAN, etc.
2. Large Objects (LOB): This type of data type stores objects that are relatively large in size and stored separately from other data types such as text, graphic images, video clips, sound, etc.
3. Composite: These type of data types have internal components that can be accessed individually. It includes records and collections.
4. Reference: As the name sounds, it includes pointers that refer to the location of the other data items.
Now, I have listed down some of the sub data types frequently used in PL/SQL
1. Numeric: Numeric values on which arithmetic operations are performed. It includes sub types such as number, decimal, real, float, etc.
2. Character: Character values on which character operations such as strings are performed. It includes sub types such as char, varchar, varchar2, nvarchar2, etc.
3. Data and Time: This data type is used to store fixed data type which displays and saves time and date values. The default data format saved into the database might be ‘DD-MM-YY’. However, you can change and alter the position of the terms accordingly.
4. Boolean: These include logical values on which logical operations are performed. The logical values are the Boolean values TRUE and FALSE and the value NULL. But, SQL has no data type equivalent to BOOLEAN. It cannot be used in SQL Statements, built in SQL functions such as To_char, PL/SQL function invoked from DQL commands.
5. Number: Syntax: Number(Precision, Scale). Fixed-point or floating-point number with absolute value in range 1E-130 to (but not including) 1.0E126. A NUMBER variable can also represent 0.
6. Float: ANSI and IBM specific floating-point type with maximum precision of 126 binary digits (approximately 38 decimal digits).
7. Integer: ANSI and IBM specific integer type with maximum precision of 38 decimal digits
8. Real: Floating-point type with maximum precision of 63 binary digits (approximately 18 decimal digits).
9. Varchar2: Variable-length character string with maximum size of 32,767 bytes.
10. Rowid: Physical row identifier, the address of a row in an ordinary table.
11. Bfile: Used to store large binary objects in operating system files outside the database System-dependent. Cannot exceed 4GB.
12. Blob: Used to store large binary objects in the database. Memory Capacity: 8 to 128 TB.
13. Clob: Used to store large blocks of character data in the database. Memory Capacity: 8 to 128 TB.
14. Nclob: Used to store large blocks of NCHAR data in the database. Memory Capacity: 8 to 128 TB.
Note: A variable in PL/SQL program code can be assigned a NULL value i.e., ‘’. However, it cannot be equated with any other variable or even itself.
Syntax Variable-Name DataType(Precision/Dimension)
Example Emp_name varchar2(30)
Here, Emp_name is the variable name and varchar2 is the data type with the 30 as the precision or the dimension. It is allowed to assign values during declaration of a variable in the declaration block. Setting the precision as 30 allows us to assign a string value of not more than 30 characters for that particular variable.
There are many more PL/SQL data types used in PL/SQL programming language. Since, this tutorial is especially for beginners, we just want you to first grasp the basic understanding and then jump into deeper details. These mentioned are sufficient for you to get started into PL/SQL programming. However, we shall mention new data types at regular intervals later.
If you find anything incorrect In above tutorial then please mention it by commenting below. You can also ask your queries.
每种编程语言都有内置的数据类型,这些数据类型用于声明变量和许多其他相关任务。 变量不过是存储空间的名称。 每个变量都有一个数据类型,该数据类型指定存储格式,一组指定值,变量范围以及许多其他因素。
变量必须在PL / SQL程序的声明部分中定义。 但是,如果不是必需的,则不必在PL / SQL程序中包括声明部分和变量声明。
PL / SQL中使用的数据类型如下:
| 图片来源 |
1.标量:这些数据类型不包含任何内部组件。 它包括诸如NUMBER,DATE,BOOLEAN等数据类型。
2.大对象(LOB):这种类型的数据类型存储的对象相对较大,并且与其他数据类型(例如文本,图形图像,视频剪辑,声音等)分开存储。
3.组合:这些类型的数据类型具有可单独访问的内部组件。 它包括记录和收藏。
4.参考:听起来很像,它包括指向其他数据项位置的指针。
现在,我列出了PL / SQL中经常使用的一些子数据类型
1.数值:对其执行算术运算的数值。 它包括子类型,例如数字,小数,实数,浮点数等。
2.字符:在其上执行字符操作(例如字符串)的字符值。 它包括子类型,例如char,varchar,varchar2,nvarchar2等。
3.数据和时间:此数据类型用于存储显示和保存时间和日期值的固定数据类型。 保存到数据库中的默认数据格式可能是“ DD-MM-YY”。 但是,您可以相应地更改和更改条款的位置。
4.布尔值:这些值包括对其执行逻辑操作的逻辑值。 逻辑值是布尔值TRUE和FALSE和值NULL。 但是,SQL没有等效于BOOLEAN的数据类型。 它不能在SQL语句中使用,SQL语句内置了SQL函数,例如To_char,从DQL命令调用的PL / SQL函数。
5.数字:语法:数字(精度,小数位数)。 绝对值在1E-130到(但不包括)1.0E126范围内的定点或浮点数。 NUMBER变量也可以表示0。
6.浮点数: ANSI和IBM特定的浮点类型,最大精度为126个二进制数字(约38个十进制数字)。
7.整数: ANSI和IBM特定的整数类型,最大精度为38个十进制数字
8.实数:浮点类型,最大精度为63个二进制数字(约18个十进制数字)。
9. Varchar2:可变长度字符串,最大大小为32,767字节。
10. Rowid:物理行标识符,是普通表中一行的地址。
11. Bfile:用于将大型二进制对象存储在依赖于系统的数据库外部的操作系统文件中。 不能超过4GB。
12. Blob:用于将大型二进制对象存储在数据库中。 内存容量:8到128 TB。
13. Clob:用于在数据库中存储大块字符数据。 内存容量:8到128 TB。
14. Nclob:用于在数据库中存储NCHAR数据的大块。 内存容量:8到128 TB。
注意: PL / SQL程序代码中的变量可以分配一个NULL值,即“''。 但是,它不能等同于任何其他变量甚至本身。
语法 变量名称数据类型(精度/尺寸)
示例 Emp_name varchar2(30)
在这里,Emp_name是变量名称,而varchar2是数据类型,其精度或维数为30。 允许在声明块中声明变量期间分配值。 将精度设置为30允许我们为该特定变量分配不超过30个字符的字符串值。
PL / SQL编程语言中使用了更多PL / SQL数据类型。 由于本教程特别适合初学者,因此我们只希望您首先掌握基本的知识,然后再深入了解更多细节。 提到的这些内容足以让您开始使用PL / SQL编程。 但是,稍后我们将定期提及新的数据类型。
如果您发现任何不正确的内容,请在下面的评论中提及。 您也可以询问您的问题。
翻译自: https://www.thecrazyprogrammer.com/2015/05/plsql-data-types.html
来源:网络
今天客户那边登录跳转不到,堡垒机限制不能直接连生产环境数据,只能将生产环境上的数据搬迁过来。 oracle导出成dmp,sql等格式都有问题,要么乱码,要么字段无法匹配,所以导出成csv文件。 1.oracle数据导出csv文件 先执行select * from td_user; 将所有数据显示,之后导出成csv文件。 2.navicat导入csv文件 (1)右键导入向导 (2)选中csv文件 (...
1.从navicat导出excel 导出成excel文件,之前直接导出csv文件,结果pl/sql无法自动匹配字段, 2.编辑excel文件,给第一列加上字段名,另存为csv文件。 3.将文件导入PL/SQL 选择工具-->文本导入器 按图中蓝色字依此选择,1选中我们的csv文件,2选择导入到oracle的数据,3选择导入的数据库,4选择导入的数据库表, 选中后字段名会自动匹配。5.导入...
PL / SQL - 快速指南 PL / SQL - 概述 PL / SQL编程语言是由Oracle公司在20世纪80年代后期开发的,作为SQL和Oracle关系数据库的过程扩展语言。以下是关于PL / SQL的一些值得注意的事实 - PL / SQL是一种完全可移植的高性能事务处理语言。 PL / SQL提供内置,解释和OS独立的编程环境。 PL / SQL也可以直接从命令行SQL...
当需要执行一段代码多次时可能会出现以下这种情况:一般来说,语句依次执行,首先执行函数中的第一个语句,然后执行第二个语句,依此类推。 编程语言提供了允许更复杂的执行路径的各种控制结构。 循环语句允许多次执行一个语句或一组语句,以下是大多数编程语言中循环语句的一般流程图 - PL/SQL提供以下类型的循环来处理循环需求。可点击以下链接查看每个循环类型如何使用。 编号 循环类型 描述 1 PL/SQL基...
一、异常处理的三种方式 异常处理通常在PL/SQL结构的后半部,结构为 EXCEPTION WHEN 异常1名字 THEN 处理方法; WHEN 异常2名字 THEN 处理方法; WHEN OTHERS THEN 处理方法; 二、预定义的异常处理 1.部分ORACLE 预定义的异常错误如下图所示: 2.举例:当select into语句返回多条数据给一个变量...
一、游标的概念 游标类似于java中的迭代器,可以挨个遍历查询的结果集。(个人理解) 二、显式的游标处理 1.游标处理分四步,第一步:定义游标;第二步:打开游标;第三步:提取游标数据;第四步:关闭游标。 当然也可以再提取游标数据的时候将游标的数据放到一个记录类型的变量里,只需要与定义游标时的字段类型按顺序匹配即可。 2.在提取游标数据的时候,会用到一些游标属性,如上图中的 emp_sal_curs...
Oracle创建一个称为上下文区域的内存区域,用于处理SQL语句,它包含处理该语句所需的所有信息; 例如,处理的行数等。 游标是指向此上下文区域的指针。PL/SQL通过游标控制上下文区域,游标保存SQL语句返回的行(一个或多个)。 游标所在的行集称为活动集。 可以命名一个游标,以便在程序中引用它来获取和处理SQL语句返回的行,一次处理一个(行)。PL/SQL中有两种类型的游标 - 隐式游标 显式游...
PL/SQL的安装 PL/SQL的安装 PL/SQL的安装清单 安装清单的注意事项 安装 官方安装文档 PS PL/SQL的安装 网上看了一大堆PL/SQL的安装感觉怪怪的,各种Oracle客户端安装下载,还有Oracle服务端下载安装,似乎是太繁重了,不够精简,真是的要什么自行车~,我只想连接公司的Oracle服务器去搞事 PL/SQL的安装清单 PL/SQL的安装包,下载地址 Oracle C...
投身IT,不是在踩坑路上,就是在往坑的路上。手握指南,犹如茫茫大海中,而不至于饿船毁人亡。 阅读全文: http://gitbook.cn/gitchat/activity/5e663433b2e56b0d65b51006 您还可以下载 CSDN 旗下精品原创内容社区 GitChat App ,阅读更多 GitChat 专享技术内容哦。...
【背景】 经过一些Android中EditText方面的折腾: 【已解决】android中的EditText控件没有获得焦点但是输入法却弹出显示->Activity中不要默认就显示输入法 【暂未去解决】Android中EditText如何在失去焦点后让输入法消失 【已解决】Android中EditText点击获得焦点后无法显示输入法键盘 然后对于EditText(或TextView)中的In...
I'm trying to send notification to employees, i created a computed many2many field to get the partners id and pass them to partner_ids field of the mail.wizard.invite model. here is my inherited class...
I am in the process of writing a diff text tool to compare two similar source code files. There are many such "diff" tools around, but mine shall be a little improved: If it finds a set of l...
How would I go about adding a 3D object from Maya into an iOS app? For now, before it gets too complicated, I just want to add it in, no response to touch yet. Is there a tutorial about this? Thanks! ...
I have a relatively simple task although I am just a beginner so it's difficult to proceed. I have a list of users on the left and a right panel to show that users info. The information about the user...
I want to have a URL path pattern like this: Both first segment and the second segment are composed of integer values. In case this pattern is not met, I want routing to fallback to the default {contr...