Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common methods of inserting data in sql

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what are the common methods of sql inserting data". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the common methods of sql inserting data?"

The copy code is as follows:

INSERT INTO table1 (id, name, address) VALUES (1, ygl, 'beijing') is suitable for T-sql and PL/SQL

SELECT id, name, address INTO table2 FROM table1 automatically create table2,T-sql usage

INSERT INTO table2 (id, name, address) SELECT id, name, address FROM table1

Let's briefly talk about the third sentence here. Because you can specify the columns to be inserted into the talbe2 and get the data source through relatively complex query statements, it may be more flexible to use, but we must also note that when we specify the columns of the target table, we must fill in all the non-empty columns, otherwise we will not be able to insert the data. When we write it in the following abbreviated format:

The copy code is as follows:

INSERT INTO table2 SELECT id, name, address FROM table1

At this point, if we omit the columns of the target table, all the columns of the target table will be inserted by default, and the order of the columns after SELECT must be exactly the same as the definition order of the columns in the target table in order to complete the correct data insertion, which is easy to be ignored and should be noted.

Thank you for your reading, these are the contents of "what are the common methods of sql inserting data?" after the study of this article, I believe you have a deeper understanding of what the common methods of sql inserting data have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report