The use of the SQL interactive query tool of Dameng Database

1. Login method

1.1 SQL interactive query tool login login method

  1. Windows/Linux ( Dameng graphical tools have been installed ) use the login command to log in to the Dameng database, as shown in the figure below:
Insert picture description here
  2. Click the Enter key, and after clicking it, you will be prompted to enter the service name (that is, the IP address of the server node where the DM is located ), As shown in the figure below:
Insert picture description here
  3. Click the Enter key, and after clicking, you will be prompted to enter the user name (also equivalent to the mode name, in general, the mode name and the user name are consistent), here you can use the super user'SYSDBA' to log in. As shown in the figure below:
Insert picture description here
  4. Click the Enter key, and then enter the password corresponding to the user. It is invisible when you enter the password. Just click Enter after you enter it, as shown in the figure below:
Insert picture description here
  5. You will be prompted to enter the port number, here generally the port number is 5236, want to connect to a different database instance corresponding to the input port number (in the absence of creating a new instance of a database, the default port number is 5236), as shown below:
Insert picture description here
  6. click enter to Yes, after entering the port number, you can keep pressing the Enter key for the information that is prompted to enter later. After the login is successful, there will be a prompt message, as shown in the following figure:
Insert picture description here

1.2 SQL interactive query tool conn login method

  First, open the "Interactive Query Tool" of DM and enter the following command:

conn 用户名/密码@IP地址(示例:conn SYSDBA/SYSDBA@localhost)

Then click Enter . The information for successful login is the same as the prompt information for login using login .

1.3 linux system login

  This login method is used when the linux system does not have Dameng 's SQL interactive query tool. In this case, we need to find disql to enter the interactive command window. First, we must first enter Dameng in Linux In the bin directory of the system installation location , then execute the following command:

./disql 用户名/密码@IP地址(示例:./disql SYSDBA/SYSDBA@localhost)

In this way, you can enter the interactive query window.

2. Query of schema and table

2.1 All modes of query

  In Dameng database, strictly speaking, different databases represent different database instances. Each database instance has its own port number. Different modes in a database instance can be understood as different libraries in mysql (just so That’s it. Strictly speaking, it is not. Different modes correspond to different users. Strictly speaking, the modes are for better division of user permissions), so there is no way we can use show databases like mysql. Command, but Dameng database provides us with several views so that we can view the detailed information of the mode. The query statement is as follows:

/*因为达梦数据库中创建一个用户就会自动创建和用户名保持一致的模式名,所以
一般情况下,下面这个sql中的USERNAME就是库中所有的模式名。*/
SELECT USERNAME FROM DBA_USERS;

The query result is shown in the figure below:
Insert picture description here

2.2 Query of all tables

  We can use the following query statement to view all the tables in the current library, as shown below:

/*OWNER代表的就是模式名字,TABLE_NAME就是表名*/
SELECT OWNER,TABLE_NAME FOM ALL_TABLES;

The query result is shown in the following figure:
Insert picture description here
This will list all the data tables in the current library, but it is rarely used in this way, because there are many system tables, and in fact, it is rare to view the full scale.

2.3 View all tables in a mode

  When we check which tables are available, we generally want to see which data tables are in a certain mode. For example, I want to query all tables in JL mode. The statement is as follows:

/*这种查询语句相信大家应该都是掌握的,只是需要了解需要查询哪张表来得到自己
需要的结果,实际ALL_TABLES是一个达梦库提供的视图*/
SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER='JL'

The query result is shown in the figure below:
Insert picture description here

2.4 Get the current mode name

  When using the interactive command window, we can get the current mode through the command, as shown below:

SELECT SYS_CONTEXT ('userenv', 'current_schema') FROM DUAL;

The query result is shown in the figure below:
Insert picture description here

2.5 View table structure

  In the command line, we can use DESC to view the table structure, as shown below:

/*DESC 模式名.表名字*/
DESC JL.T_P2;

The query result is shown in the figure below:
Insert picture description here

3. Execute sql script

3.1 Two ways to execute sql scripts

1. Execute the script through the start command, as shown below:

start F:\test.sql

The content of the script is as follows:

SELECT * FROM JL.T_P2;

The execution result is as follows:
Insert picture description here
2. Execute the script through the "Gone" –>[`] command, as shown below:

` F:\test.sql;

The execution results are as follows: SQL scripts
Insert picture description here
can be executed through the above two methods .

Guess you like

Origin blog.csdn.net/AnameJL/article/details/113449681