1.%type
You can use%type when you define a variable whose data type is the same as the type of a data variable that you have defined, or is the same as the data type of a column in a database table.
To put it bluntly is to assign the result of a column you are querying to a variable that will use the%TYPE.
---to inquire about the declareempcom Emp.comm%type of the employee number 7369 subsidy; -- Declare a empcom variable with data type Type Comm column type of EMP table begin Select comm into empcom from EMP where empno=7369;--- Place the result value of the Comm type found in the empcom variable dbms_output.put_line (' Employee subsidy is ' | | empcom);---| | is the connection character end;
The Declare declaration section defines a empcom variable whose type is the Comm property of the EMP, meaning that the next program assigns the value of the column to the empcom variable.
Select Comm to empcom from EMP where empno=7369;
Select ... into ... Indicates that the query result is assigned to empcom.
2.%rowtype
PL/SQL provides the%rowtype operator, which returns a record type whose data type is consistent with the data structure of the database table.
How to use: Variable name. Column Name
The advantage of using the%rowtype feature is that:
The number of columns in the referenced database and the data type can be unnecessary to know;
The number of columns and data types in the referenced database can be changed in real time.
The records that take out a column can be stored in a variable defined using RowType.
---query all the information of King employees. %rowtype using declareempmsg emp%rowtype; --Define a empmsg variable to save a row of data begin
Plsql two attribute types%type and%rowtype