===========================================================================
Note that each time the client inputs a statement, it must be added;
show databases;
--format create database [Database name]; create database test;
Note: you cannot create a database with the same name
--format use[Database name] use test;
Note: each time you want to operate a table in the database, you must first execute the use [database name] statement
--format drop database [Database name]; drop database test;
After the database is deleted, all the tables and data in it are deleted.
============================================================================
Integer and decimal types
|Data type (integer) | size and description|
| — | — |
|bit[(M)] | M specifies the number of bits, which is 1 by default|
|tinyint | 1 byte|
|smallint | 2 bytes|
|int | 4 bytes|
|bigint | 8 bytes|
|Data type (decimal) | size and description|
| — | — |
|float(M,D) | 4 bytes (single precision M is the number of significant digits, D is the number of decimal digits, and precision loss will occur)|
|double(M,D) | 8 bytes|
|decimal(M,D) | M/D MAX + 2 (most used, M is the number of significant digits, D is the number of decimal digits) is more accurate, but the calculation is slow|
|numeric(M,D) | M/D MAX + 2|
|Data type | size and description|
| — | — |
|varchar(size) | 0~65535 bytes (size is defined according to requirements. If the string is longer, it is defined as larger, and if it is shorter, it is defined as smaller)|
|text | 0~65535 bytes|
|mediumtext | 0~16777215 bytes|
|blob | 0~65535 bytes|
|Data type | size and description|
| — | — |
|datatime | 8-byte range makes it impossible to retrieve and convert time zones from 1000 to 9999|
|timestamp | 4-byte range enables automatic retrieval and conversion of the current time zone from 1970 to 2038|
Time stamp is also the basic way for computer to store and represent time, because it has small space and is easy to calculate
=========================================================================
You need to operate the tables in the database. You need to use the database first
--format desc [[table name] desc test;
Note: there is no table keyword
--format create table [[table name]; create table test;
show tables;
Note: add s
--format drop table [[table name]; drop table test;
Example: define a book list with book name, author name, price and category.
create database test; --Create a database use test; --Select test Database operation create table books(bookname varchar(64),bookauthor varchar(64),bookprice decimal(4,2),category varchar(32)); --Create book name (string type), author name (string type), price (4 significant digits, 2 digits after the decimal point), and type (string type).
A very simple book list has not been added, deleted, modified and checked.
4, Addition, deletion, modification and query of MySQL table
================================================================================
--format --insert [into] [[table name] valuse; Full column insert [into] Can be omitted --insert [into] (Field name) valuse; Specify column (field name) insertion [into] Can be omitted
1. Insert single row data into all columns
insert into books values ('Ordinary world','Rotel ',79.99,'novel');
2. Multi row data full column insertion
insert into books values ('The Ricksha Boy','Lao She',68.99,'novel'), ('Xu Sanguan selling blood','Yu Hua',49.99,'novel');
3. Insert specified column of single row data
insert into books (bookname,bookauthor,bookprice)values ('White Deer Plain','Chen Zhongshi',72.80); insert into books (bookname,bookprice,category)values ('Principle of computer composition',72.80,'Computer class');
Note that when inserting the specified column element, it must match the type of the specified column.
4.2. 1. Full column query
--format select * from [[table name]; select * from books;
4.2. 2 specify column query
--format select ((specify field) from [[table name]; select bookname from books;
Designated Title:
4.2. 3 queries containing expressions
-- format selcet (Specify field)+expression from [[table name]; select bookname,bookprice+10 from books;
Add 10 yuan to the price of each book
4.2. 4 alias query
--format select (field) [as] alias from [[table name];
Add discount attribute
select bookprice*(discount/100) as declineprice from books; --How much is the discount
4.2. 5 weight removal
Use the distinct keyword to de duplicate a column of data
The preferential margin for weight removal is 10
--format select distinct (Field name) from [[table name]
4.2. 6 sorting
Use the keyword order by
asc is in ascending order (from small to large)
desc is in descending order (from large to small)
The default is ASC
--format : select (The name of the field to display) from [[table name] order by (Fields to sort) (asc)//asc can be omitted -- select (The name of the field to display) from [[table name] order by (Fields to sort) desc //Descending order
4.2. 7 condition query
Comparison operator:
last
In fact, it can be seen from the recruitment needs of large factories that high concurrent experience in recruitment requirements is preferred, including many friends who used to work in traditional industries or outsourcing projects. They have been working in small companies. The technology is relatively simple, and they have not done much distributed systems, but now Internet companies generally do distributed systems.
Therefore, if you want to enter a large factory and break away from traditional industries, these technical knowledge are necessary for you. Now I have made a mind map of Java concurrency system by myself, hoping to help you.
[table name] order by (asc) / / asc can be omitted
– select from [table name] order by desc / / descending
![Insert picture description here](https://img-blog.csdnimg.cn/20210530173537661.png) ### []( )4.2. 7 condition query Comparison operator: # last In fact, it can be seen from the recruitment needs of large factories that high concurrent experience in recruitment requirements is preferred, including many friends who used to work in traditional industries or outsourcing projects. They have been working in small companies. The technology is relatively simple, and they have not done much distributed systems, but now Internet companies generally do distributed systems. Therefore, if you want to enter a large factory and break away from traditional industries, these technical knowledge are necessary for you. Here's a copy by yourself Java Concurrent system mind map, hope to help you. **[CodeChina Open source project: [first tier big factory] Java Analysis of interview questions+Core summary learning notes+Latest explanation Video]](https://codechina.csdn.net/m0_60958482/java-p7)** ![](https://img-blog.csdnimg.cn/img_convert/d8c9b612ad20b889af080d1480d0bc3f.png)