MySQL database specifically some operations

Creating a database:
the CREATE DATABASE database name;
delete the database:
drop Database <database name>;
choose to use (the database to be operated):
use the database name;
MySQL database data types:
Type Size range (signed) range (unsigned) use
TINYINT 1 byte (-128,127) (0,255) small integer
SMALLINT 2 bytes (-32 768,32 767) (535 0,65) large integer
MEDIUMINT 3 bytes (388 -8388 608,8 607) (0,16 777,215) large integer
INT or iNTEGER 4 bytes (-2 147 483 147 483 647 648,2) (0,4 294,967,295) large integer
BIGINT 8 bytes (-9,223,372,036,854,775,808,9 223,372,036,854,775 807) (0,18 446,744,073,709,551 615) maximum integer
FLOAT 4 bytes (-3.402 823 466 E + 38, -1.175 494 351 E-38), 0, (1.175 494 351 E-38,3.402 823 466 351 E + 38) 0, (1.175 494 351 E-38,3.402 823 466 E + 38) single-precision
floating-point value
DOUBLE 8 bytes (-1.797 693 134 862 315 7 E + 308, -2.225 073 858 507 201 4 E-308), 0, (2.225 073 858 507 201 4 E-308,1.797 693 134 862 315 7 E + 308 ) 0, (2.225 073 858 507 201 4 E-308,1.797 693 134 862 315 7 E + 308) double-precision
floating-point value
DECIMAL to DECIMAL (M, D), if M> D, M + 2 is otherwise D and D M + 2 depends on the value depends on the value M and a small value of D
to create the tables:
the CREATE tABLE runoob_tbl` the IF the NOT EXISTS `(
` runoob_id` the INT UNSIGNED the AUTO_INCREMENT,
`runoob_title` VARCHAR (100) the NOT NULL,
` runoob_author VARCHAR `(40) the NOT NULL,
` submission_date` DATE,
a PRIMARY KEY ( `runoob_id`)
) = ENGINE the InnoDB the DEFAULT the CHARSET = UTF8;
drop tables:
the DROP tABLE <table name>;
insert data:
the iNSERT the INTO table_name (field1, Field2, ... fieldN)
VALUES
(Value1, value2, ... valueN) ;
query data:
SELECT <Field Name> from <table name>;
SELECT * from <table name>; (all fields in query information in the data table)
the WHERE: condition judgment statement
the SELECT field1, Field2, ... fieldN the fROM table_name1, table_name2 ...
[the WHERE condition1 [the AND [OR]] condition2 The .....
example:
the SELECT * from the WHERE ID = fact_huishoubao_setting 'millet';
the uPDATE: update a a line information table where the data in
the UPDATE table_name the SET field1 = new new-VALUE1, Field2 = new new-value2
[the wHERE Clause]

the UPDATE <table name> the SET <modify field properties (this may not be modified)> = '<need modified fields attribute value> 'the WHERE <field is determined according to properties (this may not be modified)> =' <attribute value is determined based on the field of> ';

Update stage.fact_crawl_platform_itemid_map_sku_id
SET sku_id = "{}"
WHERE itemId = "{ } ";
sku_id is a need to modify the value, itemID we modify the property values according itemID;
DELETE: delete a row for a field information
The FROM table_name the DELETE [the WHERE Clause];
the DELETE the FROM <table name> the WHERE <attribute> = <attribute value>;
<attribute> = <attribute value> is the basis for the determination
LIKE :( similar =)
the SELECT field1, Field2, fieldN ...
the FROM table_name
the WHERE field1 the LIKE condition1 [the AND [OR]] = filed2 'someValue'

NUION :( for connecting two or more SELECT statement)
SELECT expression1 the, expression2 the, ... expression_n
the FROM Tables
[the WHERE Conditions]
the UNION [ALL | DISTINCT]
the SELECT expression1, expression2, ... expression_n
the FROM the Tables
[the WHERE Conditions];

expression1, expression2, ... expression_n: to retrieve the column.

tables: to retrieve the data table.

WHERE conditions: optional search condition.

DISTINCT: Optional, delete duplicate the results of the data set. By default, the UNION operator has removed the duplicate data, so the impact on the results DISTINCT modifier nothing.

ALL: Alternatively, return all the result sets that contain duplicate data.

Example:
the SELECT Country the FROM Websites
the UNION
the SELECT Country the FROM Apps
the ORDER BY Country;
sort: (the ORDER)
the SELECT field1, Field2, ... fieldN table_name1, ... table_name2
the ORDER BY field1 [the ASC [DESC] [Default ASC]], [ field2] [ASC [DESC] ... [ default the ASC]]
the gROUP BY :( packet)
the SELECT column_name, function (column_name)
the FROM table_name
the WHERE column_name operator value
the gROUP BY column_name;

example:
the SELECT name, COUNT (*) the FROM employee_tbl the gROUP name BY;

the SELECT name, the SUM (Singin) the FROM AS singin_count the WITH employee_tbl the GROUP BY name the ROLLUP;
--------------------- 

Guess you like

Origin www.cnblogs.com/ly570/p/10987489.html