Dameng database DISQL common commands

1. HELP

Function: It can help users to view the specific usage of other commands. Users can see what other command systems display.

The syntax is as follows:

HELP  <command>

Examples are as follows:

2. Output file SPOOL

Function: output the content displayed on the screen to the specified file

The syntax is as follows:

SPOOL {<file> | OFF }

<file>::= <file_path> [CRE[ATE]|REP[LACE]|APP[END]]

<file_path>: the absolute path of the specified file

CRE[ATE]: Create the specified file. If the specified file already exists, an error will be reported. The default method

REP[LACE]: create the specified file, if the specified file already exists, replace it

APP[END]]: Append the output to the end of the specified file

OFF: Turn off SPOOL output

Examples are as follows:

3. Switch to the operating system command HOST

Function: Use the HOST command to execute operating system commands without exiting DIsql. If the host is executed separately, you can switch directly from the DIsql interface to the operating system, and then use EXIT to return to the DIsql interface. 

The syntax is as follows:

HOST [<command>]

Examples are as follows:

4. Obtain object structure information DESCRIBE

Function: Get the structural description of tables or views, stored procedures, functions, packages, records, and classes.

The syntax is as follows:

  DESC[RIBE] <table>|<view>|<proc>|<fun>|<pkg>|<record>|<class> 

Examples are as follows:

 

5. Define the local variable DEFINE

Function: It is used to define a substitution variable of a local variable, and then assign a value of CHAR type to the variable; or output the value and type of the variable.

The syntax is as follows:

DEF[INE] [<VARIABLE=text>|< VARIABLE >]

DEF[INE] VARIABLE = text: Declare a variable, if the variable exists, re-assign it, otherwise create a new variable and assign it.

DEF[INE] VARIABLE: If the variable exists, output the value and type of the specific VARIABLE, otherwise an error will be reported.

DEF[INE]: Output the value and type of all variables in DIsql.

The substitution variables defined by this command can work in both the current DIsql environment and the /NOLOG environment. The variables defined by DEFINE will be saved in the environment DIsql environment and can be used in SQL statements. The default variable prefix is ​​&.

Examples are as follows:

The DEFINE variable is defined as an integer example as follows:

 Use in stored functions

Define the variable C2 as an expression, and parentheses must be added when it is defined as an expression

DEFINE variables are defined as characters

Reference variables as function parameters

DEFINE variable is defined as date type

6. View the execution plan EXPLAIN

Function: Use the EXPLAIN command to view the execution plan of the query statement.

The syntax is as follows:

  EXPLAIN <sql_clause>

  <sql_clause> Please refer to "DM_SQL"

Examples are as follows:

7. Set the exception handling method WHENEVER

Function: Use the WHENEVER command to set the exception handling method, continue execution or exit DIsql.

The syntax is as follows:

WHENEVER SQLERROR

CONTINUE [ COMMIT | ROLLBACK | NONE ] |

EXIT [ SUCCESS | FAILURE | WARNING | n | <variable>

| : <bindvariable> ]

[ COMMIT | ROLLBACK ]

The return value of n and <variable> is limited by the operating system, and it will be different under different platforms, for example:

The UNIX system only uses one byte to store the code, so the range of the return value is only between 0-255.

--In the windows system, enter echo %ERRORLEVEL%, and check the return value: 1

--Under the linux system, enter echo $?, check the return value: 1

8. View the next result set MORE

Function: When there are too many result sets and the screen can only display one, the user can use the MORE command to switch to the next result set.

Syntax: MORE

Examples are as follows:

9. Display SQL statement or block information LIST

Displays information about recently executed SQL statements or PL/SQL blocks. DIsql commands are not displayed.

Guess you like

Origin blog.csdn.net/qq_35273918/article/details/129933769