SQL Basics--New_value use

Source: Internet
Author: User

--===============================

--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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.