In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Basic data types--
1. Numerical type
NUMBER (PMAE S)
The parameter P represents the precision and the parameter S represents the scale range.
Precision refers to the number of all significant digits in the value, while the scale range refers to the number of decimal places to the right of the decimal point.
Subtypes are type aliases equivalent to NUMBER.
Subtypes: DEC, DECIMAL, DOUBLE, INTEGER, INT, NUMERIC, SMALLINT, BINARY_INTEGER, PLS_INTEGER
two。 Character type
Character types: VARCHAR2, CHAR, LONG, NCHAR, NVARCHAR2
These types of variables are used to store string or character data.
VARCHAR2 (maxlength)
The parameter maxlength represents the maximum length of a string that can be stored, which must be given when defining a variable (because the VARCHAR2 type does not have a default maximum length).
The maximum value of the parameter maxlength can be 32767 bytes.
CHAR (maxlength)
The maximum value of the parameter maxlength can be 32767 bytes.
The default maximum length of the CHAR type is 1 byte. If the value assigned to a variable of type CHAR is less than maxlength, complete it with a space after it.
3. Date Typ
DATE
4. Boolean type
BOOLEAN
Its variable value can be one of TRUE, FALSE, NULL.
-Special data types--
1.% TYPE type
Use the% TYPE keyword to declare a data type with the same name as the specified column, which usually follows the specified column.
Example:
Declare a variable var_job that is exactly the same data type as the job column in the emp table
Declarevar_job emp.job%TYPE
2. RECORD type, also known as "record type"
Type record_type is record (var_member1 data_type [not null] [: = default_value],... var_membern data_type [not null] [: = default_value])
Record_type: represents the name of the record type to be defined.
Var_member1: represents the name of the member variable of the record type.
Data_type: represents the data type of the member variable.
Example:
Declare a record type emp_type, then use a variable of that type to store a record information in the emp table and output that record.
Declaretype emp_type is record-- declares record type emp_type (var_ename varchar2 (20),-- definition field / member variable var_job varchar2 (20), var_sal number); empinfo emp_type;-- definition variable beginselect ename,job,salinto empinfofrom empwhere empno=7369;/* outputs employee information * / dbms_output.put_line ('employee' | | empinfo.var_ename | | 'job title is' | empinfo.var_job | |', salary is'| empinfo.var_sal); end;/
Output result:
The position of employee SMITH is CLERK, and the salary is 2712.5.
3.% ROWTYPE type
The variable of% ROWTYPE type combines the advantages of% TYPE type and RECORD type variable, and it can define a
A special data type used to store a row of data retrieved from a data table.
RowVar_name table_name%rowtype
RowVar_name: represents the name of a variable that can store a row of data.
Table_name: the specified table name.
Example:
Declare a variable of type% ROWTYPE rowVar_emp, and then use that variable to store a row of data in the emp table and output it.
DeclarerowVar_emp emp%rowtype;-- defines a variable beginselect * into rowVar_empfrom empwhere empno=7369;/* output employee information * / dbms_output.put_line ('employee' | | rowVar_emp.var_ename | | 'job title' | | rowVar_emp.var_job | | 'salary is' | | rowVar_emp.var_sal); end;/
Output result:
The position of employee SMITH is CLERK, and the salary is 2712.5.
-define variables and constants--
1. Define variable
[(length): =]
Example:
Var_countryname varchar2 (50): = 'China'
two。 Define constant
Constant: =
Example:
Con_day constant integer:=365
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.