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
Prerequisites Compose is a tool for orchestrating...
inherit 1. What is inheritance Inheritance: First...
Remote connection to MySQL fails, there may be th...
background In order to support Docker containeriz...
Table of contents Primary key index Create indexe...
This article example shares the specific code of ...
Be careful when listening for events that are tri...
Table of contents 1. Schematic diagram of group q...
What should I do if Linux does not support all co...
Table of contents 1. Download the MySQL installat...
Table of contents introduction Ideas Establish ID...
I wrote some Qt interface programs, but found it ...
Basic Concepts Current read and snapshot read In ...
Table of contents 1. Introduction: 2. Docker: 1 C...
Table of contents concept Array Destructuring Dec...