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
Some special characters and icons used in the pro...
This article shares the installation and configur...
Table of contents 1. Mathematical functions 2. St...
This article shares the specific code of JavaScri...
This is what happened. Today I was playing with G...
Table of contents 1. CDN introduction 1.1 react (...
01. Compile options and kernel compilation The Li...
1. Modify MySQL login settings: # vim /etc/my.cnf...
Table of contents Component Communication Introdu...
Table of contents Problem scenario: Solution: 1. ...
Hello everyone, today we will talk about how to u...
If you want to display extra text as ellipsis in ...
The react version when writing this article is 16...
When exporting data to operations, it is inevitab...
Select the category selection. After testing, IE ...