Intellij Idea 简明教程
Intellij Idea - Databases
IntelliJ 提供数据库工具,允许您直接在 IDE 中执行与数据库相关的操作。它支持所有主要数据库,如 MySQL、Oracle、Postgress、SQL server 和更多数据库。本章将讨论 IntelliJ 如何支持 MySQL 数据库。
IntelliJ provides database tool which allows you to perform database related operation from the IDE itself. It supports all major databases like MySQL, Oracle, Postgress, SQL server and many more. In this chapter, we will discuss how IntelliJ supports MySQL database.
我们假设读者熟悉数据库概念,并且系统中已安装并配置好所需的数据库工具。
We assume that the reader is familiar with the database concepts and the required databases’ tools are installed and configured on your system.
Create Database
首先,我们将创建一个数据库 - test_db 。在命令提示符中执行以下命令 −
To begin with, we will create a database - test_db. Execute the following command in the command prompt −

Connect to Database
按照以下步骤连接到数据库 −
Follow these steps to connect to a Database −
-
Navigate to View → Tool Windows → Database.
-
Click on the green plus icon and select Data Source → MySQL.

-
Enter the host address and click on the Test Connection button.
-
If everything goes well then it’ll show Successful as shown in above image.
-
Click on OK button to save connection.
Create table
按照这些步骤创建新表:
Follow these steps to create a new table −
-
Right-click on the database pane and select schema.
-
Select the New → Table option

-
A new window will appear. Define the table with columns, types and so on.

-
Click on the Execute button
-
Click on the Execute button
Insert Data
按照这些步骤插入数据:
Follow these steps to insert data −
-
Select table from the database pane.
-
It will open table in the new window.
-
Click on the plus icon to insert new row.
-
Click on the Submit button to make the changes permanent.

Retrieve Data
要检索数据,从数据库窗口双击 student_table。它将在新窗口中显示表数据。
To retrieve data, double-click on student_table from the database pane. It will show table data in new window.
要确保已将数据插入表中,请打开命令提示符并执行以下命令:
To ensure that the data is inserted into the table, open the command prompt and execute the following commands −
