--===============================
--The use of SQL basics--New_value
--===============================
The usual methods of use are:
Column column_name New_value var_name
New_value is to assign the obtained column value to the variable name, and then the variable name can participate in subsequent processing
The following shows the usage of New_value
[Email protected]> define length= "15"--Define variable length
[Email protected]> set Feedback off; --When the query ends, there is no record count information for the query results
[Email protected]> set Verify off; --requires that the value of the variable used is not displayed before executing the SQL statement
[Email protected]> CREATE TABLE tb1 (Old_col varchar2 (&&length)); --Create table tb1, length of column using variable length definition
[Email protected]> CREATE TABLE TB2 (New_col varchar2 (&&length)); --Create table TB2, length of column using variable length definition
[Email protected]> INSERT INTO tb1 values (' Robinson '); --Inserting records for table tb1
[Email protected]> commit;
[Email protected]> col old_value New_value Var_value; --Define column values to be saved to the variable Var_value
[Email protected]> select Old_col from TB1; --View the column old_col of the table tb1, at which point the value of Old_col is assigned to the variable Var_value
Old_col
---------------
Robinson
[Email protected]> INSERT INTO TB2 values (' &var_value '); --You can use variable Var_value to assign values here
[Email protected]> select New_col from TB2;
New_col
---------------
Robinson
[Email protected]> drop table tb1;
[Email protected]> drop table tb2;
--The following is the processing of a multiline record, and the variable Var_value uses the last obtained value as the variable value
[Email protected]> CREATE TABLE tb1 (Old_col varchar2 (&&length));
[Email protected]> CREATE TABLE TB2 (New_col varchar2 (&&length));
[Email protected]> INSERT INTO TB values (' Mark ');
[Email protected]> INSERT INTO TB values (' Martin ');
[Email protected]> col old_value New_value Var_value;
[Email protected]> select old_value from TB;
Old_value
---------------
Mark
Martin
[Email protected]> INSERT INTO TB2 values (' &var_value ');
[Email protected]> select * from TB2;
New_value
---------------
Martin
SQL Basics--New_value use