当前位置:网站首页>Dameng database all

Dameng database all

2022-07-05 06:36:00 LZYmarks

install

Refer to the official manual
https://eco.dameng.com/docs/zh-cn/start/install-dm-windows-prepare.html

DM Management tools

https://eco.dameng.com/docs/zh-cn/start/tool-dm-manager.html
 Insert picture description here

Register link

 Insert picture description here
make new connection
 Insert picture description here

Basic function description of the window

 Insert picture description here

View database instance information

adopt DM Management tools can view the information of database instances , Contains an overview of the system , Table usage space , System management , Log files , Archiving configuration and other aspects .

Select the corresponding instance , Right click on the 【 Management server 】, You can view the instance related information , As shown in the figure below :
 Insert picture description here
 Insert picture description here

Common options configuration

Through the configuration of common options , It can help daily operation , Including audit analysis tools , Shortcut key , Data migration tools , Query Analyzer , Management tools and other functions .

Select the management tool 【 window 】, Click on 【 Options 】 function , You can enter the configuration of common options . For example, select query analyzer 【 Editor 】 function , The editor display function can be modified , As shown in the figure below :
 Insert picture description here
 Insert picture description here

Tablespaces and users

Create tablespace
 Insert picture description here
Create user
 Insert picture description here
Create user
 Insert picture description here
 Insert picture description here

 Insert picture description here

Backup of database

 Insert picture description here
 Insert picture description here
 Insert picture description here

Agent job

 Insert picture description here

Create a proxy environment

 Insert picture description here

Create a scheduled backup job

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

idea Connect to Damon database

https://eco.dameng.com/docs/zh-cn/start/java-development.html

pom Of jar package

<!--  If the driver package reports an error , You can add local drivers -->
          <dependency>
             <groupId>com.dameng</groupId>
             <artifactId>dm-jdbc</artifactId>
        	 <version>1.8</version>
        	 <scope>system</scope>
        	 <systemPath>${project.basedir}/lib/DmJdbcDriver18.jar</systemPath>
          </dependency>
    </dependencies>
    <!--  Add image warehouse configuration -->
    <repositories>
        <!--  Alibaba cloud image warehouse is used to improve download speed -->
        <repository>
            <id>aliyun</id>
            <name>aliyun Repository</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <!--  Use  DM  To download the driver package -->
        <repository>
            <id>dc</id>
            <name>dc Repository</name>
            <url>http://119.96.100.222:8181/repository/maven-releases/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

 Insert picture description here
jar Put the bag here lib Under the table of contents
 Insert picture description here

Advantages of Dameng database
 Insert picture description here  Insert picture description here

DM Basic concepts of database

https://eco.dameng.com/docs/zh-cn/pm/dm_sql-introduction.html

Reserved words and identifiers

The syntax rules of identifiers are compatible with standards GJB 1382A-9X, Identifiers are divided into two categories: regular identifiers and delimited identifiers .

Formal identifiers are represented by letters 、_、KaTeX parse error: Expected 'EOF', got '#' at position 2: 、#̲ Or start with Chinese characters , It can be followed by letters 、…、# Or Chinese characters , The maximum length of a regular identifier is 128 English characters or 64 The Chinese characters . Regular identifiers cannot be reserved words .

Examples of formal identifiers :A,test1,_TABLE_B, surface 1.

When the identifier body of the delimited identifier is enclosed in double quotation marks , The identifier body can contain any character , Specially , Where two consecutive double quotation marks are used to escape into one double quotation mark .

Examples of delimited identifiers :”table”,”A”,”[email protected]#$“.
For a list of reserved words, see Appendix 1.

General data types

  1. Character data type
    CHAR type

grammar :CHAR[( length )]
function :CHAR The data type specifies a fixed length string . In the base table , Definition CHAR When a column of type , You can specify one that does not exceed 32767 As a positive integer of byte length , for example :CHAR(100). If no length is specified , Default is 1.CHAR The maximum storage length of type columns is determined by the database page size ,CHAR The corresponding relationship between the maximum storage length of data type and page size is shown in the following table 1.4.1. however , In expression evaluation , The maximum length of this type is not limited by the page size , by 32767.
This limit length only applies to the columns in the base table , When defining variables , Can not be limited by the length of this limit . in addition , The length of the column actually inserted into the table is constrained by the length of the record , The total length of each record cannot be greater than half the page size

CHARACTER type

grammar :CHARACTER[( length )]
function : And CHAR identical .

VARCHAR type /VARCHAR2 type

grammar :VARCHAR[( length )]

function :VARCHAR The data type specifies a variable length string , Usage is similar. CHAR data type , You can specify one that does not exceed 32767 As a positive integer of byte or character length , for example :VARCHAR (100) Appoint 100 bytes ;VARCHAR(100 CHAR) Appoint 100 Character length . If no length is specified , Default is 8188 byte .

In the base table , When not specified USING LONG ROW When storing options , Insert VARCHAR The actual maximum storage length of the data type is determined by the database page size , The specific maximum length algorithm is shown in table 1.4.1; If you specify USING LONG ROW Storage options , The insert VARCHAR The length of the data type is not limited by the database page size .VARCHAR The maximum length of a type in expression evaluation is not limited by the page size , by 32767;

CHAR Same as VARCHAR The difference between When the length of the former is insufficient , The system automatically fills in spaces , The latter only takes up the actual byte space . in addition , The length of the column actually inserted into the table is constrained by the length of the record , The total length of each record cannot be greater than half the page size .

VARCHAR2 The type and VARCHAR The type usage is the same .

Numerical data type

Exact numeric data type
NUMERIC type

grammar :NUMERIC[( precision [, scale ])]
( precision = There are several numbers 3.124 The accuracy of is 4 Scale is 3 ,1414.1 The accuracy of is 5 Scale is 1)

function :NUMERIC The data type is used to store Zero 、 Positive and negative fixed point numbers . among : Precision is an unsigned integer , Defines the total number of digits , The accuracy range is 1 to 38. The scale defines the number of digits to the right of the decimal point . The scale of a number should not be greater than its accuracy , If the actual scale is greater than the specified scale , Then the number of digits beyond the scale will be rounded and omitted . for example :NUMERIC(4,1) Defines the decimal point before 3 Place and after decimal point 1 position , common 4 Digit number , The scope is -999.9 To 999.9. all NUMERIC data type , If its value exceeds the accuracy ,DM An error message will be returned , If the scale is exceeded , Then the extra bits will be truncated .

If precision and scale are not specified , The default precision is 38, The scale is infinite .

DECIMAL type

grammar :DECIMAL[( precision [, scale ])]
function : And NUMERIC be similar .

DEC type

grammar :DEC[( precision [, scale ])]
function : And DECIMAL identical .

NUMBER type

grammar :NUMBER[( precision [, scale ])]
function : And NUMERIC identical .

INTEGER type

grammar :INTEGER
function :** Used to store signed integers , Accuracy of 10, Scale is 0.** The value range is :-2147483648 (-231)~ +2147483647(231-1).

INT type

grammar :INT
function : And INTEGER identical .

BIGINT type

grammar :BIGINT
function :** Used to store signed integers , Accuracy of 19, Scale is 0.** The value range is :-9223372036854775808(-263)~9223372036854775807(263-1).

TINYINT type

grammar :TINYINT
function : Used to store signed integers , Accuracy of 3, Scale is 0. The value range is :-128 ~ +127.

BYTE type

grammar :BYTE
function : And TINYINT be similar , Accuracy of 3, Scale is 0.

SMALLINT type

grammar :SMALLINT
function : Used to store signed integers , Accuracy of 5, Scale is 0. The value range is :-32768(-215) ~ +32767(215-1).

BINARY type

grammar :BINARY[( length )]
function :BINARY The data type is used to store fixed length binary data . In the base table , Definition BINARY When a column of type , The maximum storage length is determined by the database page size , You can specify a positive integer that does not exceed its maximum storage length as the column length , The default length is 1 Bytes . The maximum storage length is shown in table 1.4.1.BINARY The upper limit of type length in expression evaluation is 32767.BINARY Constant to 0x Start , Followed by the hexadecimal representation of the data , for example 0x2A3B4058.

VARBINARY type

grammar :VARBINARY[( length )]
function :VARBINARY Data types are used to store variable length binary data , Usage is similar. BINARY data type , You can specify one that does not exceed 32767 As the data length . The default length is 8188 Bytes .VARBINARY The actual maximum storage length of the data type is determined by the database page size , Specific maximum length algorithm and VARCHAR Of the same type , The upper limit of its length in expression calculation is also the same as VARCHAR The same type , by 32767.

Approximate numerical data type

FLOAT type

grammar :FLOAT[( precision )]
function :FLOAT Is a floating-point number with binary precision . This type directly uses the standard C In language DOUBLE. The precision value setting has no practical significance , Precision settings are used to ensure the compatibility of data migration , The actual accuracy is fixed inside Damon . The accuracy is in the range (1~126) Precision is ignored , If it exceeds this range, an error will be reported directly .
FLOAT Value range -1.710308 ~ 1.710308.

DOUBLE type

grammar :DOUBLE[( precision )]
function :DOUBLE Is a floating-point number with binary precision .DOUBLE The setting of type is for the compatibility of migration . This type directly uses the standard C In language DOUBLE. Accuracy and value range usage and FLOAT Exactly the same as .

REAL type

grammar :REAL
function :REAL Is a floating-point number with binary precision , But it cannot be specified by the user , The system specifies its binary precision as 24, Decimal precision is 7. Value range -3.41038 ~ 3.41038.

DOUBLE PRECISION type

grammar :DOUBLE PRECISION[( precision )]
function : This type indicates a double precision floating-point number .DOUBLE PRECISION The setting of type is for the compatibility of migration . This type directly uses the standard C In language DOUBLE. Accuracy and value range usage and FLOAT Exactly the same as .

Bit string data type

BIT type

grammar :BIT
function :BIT Type is used to store integer data 1、0 or NULL, Only 0 It turns to false , Other non empty 、 Not 0 Values are automatically converted to true , Can be used to support ODBC and JDBC The Boolean data type of .DM Of BIT The type and SQL SERVER2000 Of BIT Data types are similar .
Function and ODBC and JDBC Of bool identical .

Date time data type

Date and time data types are divided into general date and time data types 、 There are three types of time interval data types and time zone data types , Used to store dates 、 Time and interval information between them .

General date and time data types
DATE type

grammar :DATE
function :DATE Type includes year 、 month 、 Daily information , Defined ’-4712-01-01’ and ’9999-12-31’ Any valid Gregory date between .DM Support the Julian calendar , It also takes into account the historical anomalies of the transition from the Julian calendar to the Gregorian date , Don't count ’1582-10-05’ To ’1582-10-14’ Between 10 God .
DM Support SQL92 Standard or SQL SERVER Of DATE Word value , for example :DATE’1999-10-01’、’1999/10/01’ or ’1999.10.01’ It's all valid DATE value , And equal to each other . The first non 0 Before the value 0 You can also omit , for example ’0001-01-01’ Equivalent to ’1-1-1’.

TIME type

grammar :TIME[( Decimal second precision )]
function :TIME Types include 、 branch 、 Second information , Define one in ’00:00:00.000000’ and ’23:59:59.999999’ Effective time between .TIME Type decimal second precision specifies the number of digits after the decimal point in the second field , The value range is 0~6, If not defined , The default precision is 0.
DM Support SQL92 Standard or SQL SERVER Of TIME Word value , for example :TIME ‘09:10:21’,’09:10:21’ or ’9:10:21’ It's all valid TIME value , And equal to each other .

TIMESTAMP type

grammar :TIMESTAMP[( Decimal second precision )]
function :TIMESTAMP Type includes year 、 month 、 Japan 、 when 、 branch 、 Second information , Define one in ’-4712-01-01 00:00:00.000000’ and ’9999-12-31 23:59:59.999999’ Between the effective Gregory date and time .TIMESTAMP Type decimal second precision specifies the number of digits after the decimal point in the second field , The value range is 0~6, If not defined , The default precision is 6. And DATE The same type ,DM Don't count ’1582-10-05’ To ’1582-10-14’ Between 10 God .
DM Support SQL92 Standard or SQL SERVER Of TIMESTAMP Word value , for example :TIMESTAMP ‘2002-12-12 09:10:21’ or ’2002-12-12 9:10:21’ or ’2002/12/12 09:10:21’ or ’2002.12.12 09:10:21’ It's all valid TIMESTAMP value , And equal to each other .
In the syntax ,TIMESTAMP It can also be written as DATETIME.

Japan - Time interval
INTERVAL DAY type

grammar :INTERVAL DAY[( Guidance accuracy )]

function : Describe an interval of several days , The guidance accuracy specifies the value range of the day . The value range of guidance accuracy is 1~9, If not defined , The default precision is 2. for example :INTERVAL DAY(3), among DAY (3) The precision of the day is 3, Indicates that the range is negative 999 The sun is coming 999 Japan . An example of a suitable word value is :INTERVAL ‘150’ DAY.

INTERVAL DAY TO HOUR type

grammar :INTERVAL DAY[( Guidance accuracy )] TO HOUR
function : Describe an interval of days and hours , The guidance accuracy specifies the value range of the day . The value range of guidance accuracy is 1~9, If not defined , The default precision is 2. The value range of time is 0 To 23 Between . for example :INTERVAL DAY(1) TO HOUR, among DAY(1) The precision of the day is 1, Indicates that the range is negative 9 Day zero 23 Hour to hour 9 Day zero 23 Hours . An example of a suitable word value is :INTERVAL ‘9 23’ DAY TO HOUR.

There are still a lot of it

Multimedia data types

There are two formats for word values of multimedia data types : One is string , for example :’ABCD’, Two is BINARY, Such as 0x61626364.

TEXT、LONG、LONGVARCHAR、CLOB Only strings are supported .
BFILE The above two formats are not applicable .BFILE The specified file can only be accessed read-only .
Specifying precision for fields of multimedia data types is not supported .

TEXT type

grammar :TEXT
function :TEXT Is a variable length string type . The maximum length of its string is 100G-1 byte .DM Use it to store long text strings .

LONG、LONGVARCHAR( also called TEXT) type

grammar :LONG/LONGVARCHAR
function : And TEXT identical .

IMAGE type

grammar :IMAGE
function :IMAGE Used to indicate the image type in multimedia information . The image is composed of an indefinite pixel lattice , Maximum length 100G-1 byte . In addition to storing image data , It can also be used to store any other binary data .

LONGVARBINARY( also called IMAGE) type

grammar :LONGVARBINARY
function : And IMAGE identical .

BLOB type

grammar :BLOB
function :BLOB Type is used to indicate variable length binary large objects , Maximum length 100G-1 byte .

CLOB type

grammar :CLOB
function :CLOB Type is used to indicate a variable length alphanumeric string , Maximum length 100G-1 byte .

BFILE type

grammar :BFILE
function :BFILE Used to indicate binary files stored in the operating system , Files are stored in the operating system rather than in the database , Only read-only access .

Operator

Unary operator + and -
select -(-5), +NOWPRICE from PRODUCTION.PRODUCT WHERE NOWPRICE<10;

The result is :
5 6.1000

notes : stay SQL Because of the two short horizontal “–”, Express “ Comment start ”, Then the double minus sign must be -(-5), instead of –5.

When used between expressions +、-、*、/ when , Respectively means plus 、 reduce 、 ride 、 In addition to the operation . The accuracy of the results is specified as follows :

Only operations of exact numeric data types
The result type of two integer operations of the same type remains unchanged , The result type of two different types of integer operations is converted to the integer type with a larger range .

Integers and NUMERIC,DEC Etc ,SMALLINT The precision of type is fixed to 5, Scale is 0;INTEGER The precision of type is fixed to 10, Scale is 0;BIGINT The precision of type is fixed to 19, Scale is 0.

exp1+exp2 The precision of the result is the integer part length of the two ( Precision - scale ) The sum of the maximum value of and the maximum value of the two scales , The scale is the maximum of the two scales ;

exp1-exp2 The precision of the result is the sum of the maximum length of their integer parts and the maximum value of their scales , The scale is the maximum of the two scales ;

exp1*exp2 The precision of the result is the sum of the two , The scale is also the sum of the two scales ;

exp1/exp2 The result is NUMERIC type ( The default precision is 38, The scale is not limited ).

https://eco.dameng.com/docs/zh-cn/pm/dm_sql-introduction.html

String expressions

Connect ||

grammar :STR1 || STR2

(STR1 Representative string 1,STR2 Representative string 2)

The join operator operates on two operands , Each of them is the evaluation of strings belonging to the same character set . It concatenates strings in a given order , And return a string . Its length is equal to the sum of the lengths of the two operands . If one of the two operands is NULL, be NULL Equivalent to empty string .

example
select ‘ wuhan ’ || ADDRESS1 from PERSON.ADDRESS WHERE ADDRESSID=3;

The result is :
Qingcuiyuan, Qingshan District, Wuhan 1 Number

DM_SQL Language supported database schema

DM_SQL Three level relational database schema support , The external schema corresponds to the view and part of the base table , The schema corresponds to the base table , The base table is an independent table . One or more base tables are stored in a storage file , The logical structure in the storage file constitutes the internal schema of the relational database .DM_SQL The language itself does not provide manipulation statements for internal patterns .

Views are tables exported from base tables or other views ,DM Only save the definition of the view in the data dictionary . The definition is actually a query statement , Then take a name for the query statement, that is, the view name . Every time the view is called , In fact, it is to execute its corresponding query statement , The exported query result is the data of this view . So the view does not have its own data , It's a virtual table , Its data is still stored in the base table that exports the view . When the data in the base table changes , The data queried in the view also changes , therefore , The view is like a window , Through it, users can see the data within their permissions . Once defined, views can also be shared by multiple users , It is as convenient to do some operations similar to the base table on the view as it is on the base table .

in summary ,SQL The language's support for the three-level schema of relational database is shown in the following figure .

 Insert picture description here

原网站

版权声明
本文为[LZYmarks]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050623285918.html