In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you how to copy the DBeaver data sheet, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
After linking to the database through the DBeaver tool, we can achieve what we want through menus or command functions.
(1) create a database
Create a new database, as shown in the following figure:
->
After clicking the "OK" button, we may encounter a failure. At this time, we can directly achieve it through the sql statement, enter CREATE DATABASE bien_test in the SQL console, and execute the sql command to complete the creation.
(2) create a data table
Create a new table table_a under the bien_test database (any name, as long as it is a valid name), as follows:
When you click the "Save" button in the lower right corner, you are prompted with the message "Incorrect table definition; there can be only one auto column and it must be defined as a key" (the self-growing field is not the primary key). At this point, you need to specify id as the primary key in the constraint, as shown in the following figure:
Once this is set, click "Save" and you can successfully create the data table. Next, we use the menu or shortcut keys to create a new table similar to the tabel_a table format, first select tabel_a, right-click-> menu-> copy, or directly use the Ctrl+C shortcut key, and then Ctrl+V paste, and finally click the "Save" button in the lower right corner to complete the creation of the new table, we rename the table as tabel_b. Note that by copying and pasting the table, you can only copy the various configuration information of the table, and the data in the table is not copied.
(3) fill in data
Enter the following two statements in the SQL console:
Insert into bien_test.tabel_a (name, age, sex) values ('Jack', 12,' male'); insert into bien_test.tabel_a (name, age, sex) values ('Anny', 20,' female')
This allows you to populate the table_a with two pieces of sample data, as shown in the following figure:
(4) copy the data table
1. Copy through the menu
Copy the data from the data table tabel_a to the data table tabel_b, select tabel_b, right-click, and select Import data, as shown in the following figure:
->->
->
Click the red box in the image above, select the source side, and we select the tabel_a table as the source side, as shown on the right side of the image above. Next, follow the steps to click step by step. Finally, the data for tabel_b is shown in the following figure:
In this way, the copy of the data in the data table is completed. In addition, instead of creating a new table, we can directly export the data to a new table created while running through the source table. For example, if there is no tabel_ c table in the bien_test database, we do not need to create the tabel_c table in advance, and we can also copy the data of the tabel_a table to the tabel_ c table, as follows:
(1) Select the tabel_a table, right-click, and select "Export data", as shown below:
->->
(2) in the above figure, enter the new table tabel_c name in the Target column, and the Mapping column will automatically select create (for the new table) by default; next, follow the interface prompt button to complete the operation step by step. The final effect of the data in the tabel_ c table is the same as that in the tabel_ b table. Thus, when copying table data, you can export the active table directly to a new table created at run time without creating the table in advance.
2. Copy through the sql command
(1) insert select mode
In this way, you need to create a new table in advance, assuming it is a tabel_d table, before you can copy the tabel_ a table data to the tabel_ d table.
Insert into bien_test.tabel_d (name, age, sex) select name, age, sex from bien_test.tabel_a
After running the above command, the process of copying the data from the tabel_a table to the tabel_ d table is completed, and notice that all the data in the tabel_ a table is copied to the tabel_ d table.
(2) select into mode
In this way, there is no need to create a table in advance, assuming that it is a tabel_e table, and the copy of the data table can be completed by select into.
Select * into tabel_e from bien_test.tabel_a
After testing, the execution of the above statement failed in MySQL. We need to make some modifications at this time:
Create table tabel_e as select * from bien_test.tabel_a
The above command will be executed successfully, and the copy of the data will eventually be completed. It should be noted that the primary key information has not been copied in this way!
The above is all the contents of the article "how to copy the data sheet of DBeaver". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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: 210
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.