SQL Syntax Reference Manual

zhaozj2021-02-16  71

Www.mycodes.net 2002-2-28 mycodes.net by jason

DB2 provides a query language SQL (Structure Query Language) of the off-site database, which is a very spoken, easy-to-understand syntax. This language is almost per database system must be provided to indicate a connection operation, including data definition (DDL), and processing processing (DML). SQL originally spelled SEQUEL, the prototype of this language is completed in IBM San Jose laboratory with the name "System R", and the results are quite satisfactory, and decided The technical foundation of system R has developed IBM products. And the National Standards Association (ANSI) and the International Standardization Organization (ISO follows an almost IBM SQL-based standard-off language definition. Data definition DDL (Data Definition Language) Data-oriented language The language defined in the format and form, he is the first time to face each database, what is the formal relationship of the information, the table, the table, and the table, the table, the table, the table, etc. Waiting, it is necessary to plan it when you start, build form: grammar: create table table_name (Column1 Datatype [not null], column2 datatype [not null], ...) DataType - is the format of the information. See the table .Nut Null - You can not allow the information available (not yet-filled) .Primary Key - is the primary key of this table. Change the form ALTER TABLE TABLE_NAME Add Column Column_name DataType Description A field (syntax without deleting a field) ALTER TABLE TABLE_NAMEADD Primary Key Description Change The definition of the object is set to the primary key ALTER TABLE_NAMEDROP Primary key (COLUMN_NAME) Description Remove the main key definition. index CREATE iNDEX index_name oN table_name (column_name) illustrates the speed at which indexed fields in a table to increase query delete-bit integer DATATYPEssmallint16 DATATYPESQL of information form information form index_name DROP table_nameDROP interger32-bit integer decimal (p, s) P Precise value and the size of the size of the S size, the precise value P refers to a few digits of several (DIGITS) large value S is a few digits after the decimal point. If there is no special designation, the system will be set to P. = 5; s = 0. The real number of Double64-bit elements of the Float32-bit element CHAR (N) N length string, N cannot exceed 254VARCHAR (N) length is not fixed and its maximum length is a string of N, N cannot exceed 4000graphic (n) and char (n) Same, but its unit is two characters Double-Bytes, n cannot exceed 127.

This form is to support the font of the length of the two characters, such as the Chinese word vargraphic (n) variable length and its maximum length is a double-character string, and N cannot exceed 2000date contains years, the month, date .time contains Hours, minutes, second .timestamp included the year, month, day, hour, minute, second, one thousand second. After the data operation DML (Data manipulation language) is defined, the next is the operation of the data. The operation is not more in addition to adding information (Insert), query information (query), changed data (UPDATE), deleting data (delete) four modes, etc. Introduce them: Insert Into Table_name (Column1, Column2 , ...) Values ​​(Value1, Value2, ...) Description: 1. If you do not specify a column system, fill in the information in the field in the field 2. The data form of the field and the information fills must be Attached 3.Table_name can also be a landscape view_nameinsert into table_name (Column1, Column2, ...) Select Columnx, Column, ... from another_table description: You can also fill in the information of other forms after a subquery (Subquery) Data: Basic Query Select Column1, Column2, ... from Table_Name Description: Column of Table_name's specific field information is all SELECT * from table_namewhere column1 = xxx [and color "] [or column3 <> zzz] Description: 1. '*' Indicates that all fields are listed 2.where is the conditional pattern, and the qualified information is listed in Select Column1, Column2From Table_NameOrder by Column2 [Desc] Description: Order By is specified to be sorted in a certain field [DESC] means from big to small alignment, if there is no indication, it is a smaller to a large-array combination query. result.

转载请注明原文地址:https://www.9cbs.com/read-15331.html

New Post(0)