1. Operate the database1.1 Create a database
Of course, if we don't know whether the database exists, we can use the following statement to create it if it does not exist.
We can also specify the character set when creating a database.
1.2 Query the databaseQuery all existing databases
Query the creation statement of a database and the character set used
1.3 Modify the databaseModify the database character set
1.4 Delete the database
Similarly, you can also add if not exists
1.5 Using the DatabaseUsing Database
Query the name of the database currently in use
2. Operation table2.1MySQL Data Types
Question 1: Characteristics and differences between varchar and char Characteristics of char: 1. char represents a fixed-length string, and the length is fixed (for example, char(5) is stored as 5 characters even if it is less than 5 characters) Characteristics of varchar: 1. varchar represents a variable-length string, and the length is variable (for example, if varchar(5) is less than 5 characters, for example, 3 characters, then it is stored as three characters); The difference between the two: Combining the performance perspective (char is faster) and the disk space saving perspective (varchar is smaller) There is also a point that both store characters
Question 2: What is the meaning of 20 in int(20)? Refers to the length of displayed characters. 20 means the maximum display width is 20, but it still occupies 4 bytes of storage, and the storage range remains unchanged; It does not affect internal storage, but only affects how many zeros are added to the front of an int with zerofill definition, which is convenient for report display. Question 3: What is the difference between float and double? 1. Float type data can store up to 8 decimal digits and occupies 4 bytes in memory. Question 4: What is the difference between datetime and timestamp? For a timestamp field, if you do not assign a value to this field or assign a null value to this field, the current system time will be used by default. 2.2 Create Table
Sometimes we think Copy the structure of a table:
Sometimes we think Copy all the contents of a table:
Sometimes we Copy only part of the content:
Sometimes we Copy only part of the table's field structure
2.3 Query TableQuery the names of all tables in the database
Query table structure
2.4 Delete Table
2.5 Modify the tableModify table name
Modify the character set of a table
Add a column
Modify column name
Modify column type
Deleting a column
The above is the detailed content of the beginner's edition of MySQL learning on creating and manipulating databases and table DDL. For more information about MySQL database, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
>>: Example of adding attributes using style in html
Table of contents background analyze method backg...
Detailed explanation of mysql exists and not exis...
Hexo binds a custom domain name to GitHub under W...
Detailed explanation of the solution to garbled c...
What is it? Spring Boot is a sub-project of the S...
This article shares the specific code of jquery+A...
Preface During the development process, you will ...
The process of installing MySQL database and conf...
Logpoint-based replication 1. Create a dedicated ...
Preface The origin is a question 1: If your umask...
<br />When you click the link, the web page ...
It’s great to use CSS to realize various graphics...
I made a Dockerfile for openresty on centos7 and ...
For detailed documentation on installing the comp...
Table of contents 1. Introduction 2. select 2.1 Q...