Usage Summary of diasql
preface:
Last time, the DM8 database was built in linux, but it was not initialized. sql statements were tested and disql was used. This blog records the initialization under linux and summarizes how to use disql.
For the installation of DM8, please refer to my previous blog:
Link: Installation of DM8 (win and linux)
.
preparation
Initialize database
First, let's introduce the dminit tool, which needs to be started from the command line. Locate the installation directory / bin where dminit is located.
For example, initialize a database and put it in the / home/test/dmdbms directory. The data page is page_ The size is 16K.
./dminit PATH=/home/test/dmdbms PAGE_SIZE=16
My database is set as follows:
./dminit PATH=/home/dmdba/data PAGE_SIZE=16 CASE_SENSITIVE=Y EXTENT_SIZE=64 UNICODE_FLAG=1 PAGE_CHECK=0 DB_NAME=DAMENG INSTANCE_NAME=DMSERVER PORT_NUM=5236
The following is his meaning:
Initialize an instance under / home/dmdba/data. The database name is DAMENG, the instance name is DMSERVER, the port number is 5236, the page size is 16k, the cluster size is 64, and the character set is UTF8. Turn off page checking and turn on case sensitivity.
Detailed parameters can be downloaded from the official document DM8_ You can use the user manual document of dialql, or you can use "dminit HELP" to quickly view various parameters.
Initialization has been completed since then
Start service
Foreground start:
Execute the following command in the bin directory:
./dmserver /home/dmdba/dmdbms/data/DAMENG/dm.ini
Start the diasql tool
The startup methods are as follows:
1. Prompt for user name and password without parameters
2. Start with parameters
There are other parameters of disql. You can use
./disql help
To see.
For some passwords with special characters, we can log in through corresponding input methods in different operating systems, which will not be described in detail here. You can talk about it in detail when you have a chance.
If the user wants to switch to another DM database instance after entering the diasql interface. There are two implementations:
First, use the LOGIN command;
Second, use the CONN command. To log in to the remote database, you must use the IP address or network service name in the service name
Since then, we have completed the launch of the diasql tool.
Using the diasql tool
Basic database operations can be realized:
Table creation:
create table student( sno varchar2(3) not null, sname varchar2(9) not null, ssex varchar2(3) not null, sbirthday date, sclass varchar2(5), constraint pk_student primary key(sno) );
Insert data:
insert into student(sno,sname,ssex,sbirthday,sclass) values(108,'Zeng Hua','male',to_date('1977-09-01','yyyy-mm-dd'),95033); insert into student(sno,sname,ssex,sbirthday,sclass) values(105,'Kuang Ming','male',to_date('1975-10-02','yyyy-mm-dd'),95031); insert into student(sno,sname,ssex,sbirthday,sclass) values(107,'Wang Li','female',to_date('1976-01-23','yyyy-mm-dd'),95033); insert into student(sno,sname,ssex,sbirthday,sclass) values(101,'Li Jun','male',to_date('1976-02-20','yyyy-mm-dd'),95033); insert into student(sno,sname,ssex,sbirthday,sclass) values(109,'Wang Fang','female',to_date('1975-02-10','yyyy-mm-dd'),95031); insert into student(sno,sname,ssex,sbirthday,sclass) values(103,'Lu Jun','male',to_date('1974-06-03','yyyy-mm-dd'),95031);
View data:
Exit diasql
Use the EXIT/QUIT command to exit diasql
Dasql environment variable
Use the SET command to SET the environment variables of the current dialsql. And view the setting of environment variables in the current system through the SHOW command.
Use the help command to get the following information:
SET Set a system environment variable. The set value will modify the current session DISQL System settings, for example: - Set data display width - formulate HTML format - allow/Prohibit printing column headers - Sets the number of rows per page SHOW Show a DISQL System variable, or current DISQL Environment variables.
The parameters that can be set can be obtained through the help set command
As follows: (ps: I added the following comments)
where system_variable and value represent one of the following clauses: NEWP[AGE] {1|n|NONE} //Sets the separation between pages AUTOCOMMIT {OFF|ON} //Set auto submit PAGES[IZE] {14|n} //Set the number of rows on a page DEFINE {&|c|ON|OFF} //Define local variables ECHO {OFF|ON} //Displays the SQL statement being executed in the script FEED[BACK] {6|n|ON|OFF} //Displays the number of rows queried or modified by the current SQL statement HEA[DING] {ON|OFF} //Show column headers TIMING {OFF|ON} //Displays the execution time spent on each SQL statement TIME {OFF|ON} //Displays the current time of the system VER[IFY] {ON|OFF} //Lists the control command text before and after the environment variable is replaced LONG {800|n} //Sets the maximum number of bytes displayed for large field types LINESIZE {screen_length|n} //Sets the display width of one line on the screen SERVEROUT[PUT] {ON | OFF} [SIZE {n}] [FOR[MAT] {WRA[PPED] | WOR[D_WRAPPED] | TRU[NCATED]}]//Whether to print when there is printing information in the block, and the format of printing SCREENBUFSIZE {DEFAULT | n(byte)} //Sets the length of the screen buffer CHAR_CODE {GBK | UTF8 | DEFAULT} //Sets the encoding method of SQL statements CURSOR {STATIC | FORWARDONLY | DEFAULT} //Sets the type of cursor in the DPI statement handle LINESHOW {ON | OFF} //set number AUTOTRACE {OFF | NL | INDEX | ON | TRACE} //Set up tracking of execution plans and statistics DESCRIBE [DEPTH {1|n|ALL}] [LINENUM {ON|OFF}] [INDENT {ON|OFF}] //Set the display mode of DESCRIBE TRIMS[POOL] {ON | OFF} //Set the space at the end of each line in the spool file AUTORECONN {ON | OFF} //Whether to automatically reconnect ON yes, OFF no, the default is OFF LOBCOMPLETE {ON | OFF} //Set whether all large field data is taken out from the server KEEPDATA {ON | OFF} //Whether to optimize data alignment or maintain the original format of data. ON not optimized, OFF alignment optimized. The default is OFF NEST_COMMENT {ON | OFF} //Whether multiline comment nesting is supported. ON yes, OFF No. The default is OFF NULL_ASNULL {ON | OFF} //Whether to treat the incoming null as the null of the database when binding parameter input. ON yes, OFF No. The default is OFF NULL_SHOW {ON | OFF} CMD_EXEC {ON | OFF} //Whether to execute the "/" command in the file. ON yes, OFF No. The default is ON COLSEP {| text} //Sets the delimiter between columns. The default is a space CHARDEL {| text} //Sets the qualifier of the string. The default is a space FLOAT_SHOW { float_length } //Set the boundary length of FLOAT and DOUBLE types displayed by scientific counting method. The default value is 0, which means all are displayed by scientific method SQLCODE { ON | OFF } SQL_LINESHOW { ON | OFF } CONSOLE_PRINT { ON | OFF }
Let's demonstrate whether LINESHOW settings display line numbers.
Other parameters can also be set through similar usage.
The content described above is the primary use of diasql. There are also some advanced uses involving the use of scripts. Will learn later.