In Oracle, the values of two tables are inserted to each other and the values of the table itself are inserted.

Source: Internet
Author: User
There are two tables, student and otherStudent. The table information is as follows: SQLgt; descstudentnametypenullabledefacomments -------------

There are two tables, student and otherStudent. The table information is as follows: SQLgt; desc studentName Type Nullable Default Comments -------------

There are two tables, student and otherStudent. The table information is as follows:

SQL> desc student
Name Type Nullable Default Comments
---------------------------------------
NUM NUMBER
NAME VARCHAR2 (20)
AGE NUMBER Y

SQL> desc otherStudent
Name Type Nullable Default Comments
---------------------------------------
NUM VARCHAR2 (50)
NAME VARCHAR2 (50)

Perform the following experiments:

Lab 1

Now student has data. I want to insert the data into otherStudent.

Insert into otherStudent (num, name) select num, name from student

The inserted fields of the two tables can still be inserted if they have the same type or length. This means that as long as the inserted Table can receive the inserted fields, the type or length will not affect them.

Lab 2

OtherStudent has data. You can insert the data from this table to this table.

Insert into otherStudent select * from otherStudent

Lab 3

Statement insert into otherStudent select * from student. The error "too many values" is reported ".

Statement insert into student select * from student otherStudent. The error "not enough value" is reported ".

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.