mysql Basic Tutorial Library and Table Details

  • 2021-06-28 14:22:06
  • OfStack

MySQL is a large database.Some databases contain a wide variety of data.It looks messy if you don't divide it up according to the rules.Everything needs to be sorted out to be able to behave properly. Every stack of data is sorted out once, and then there's the thing that produces tables and libraries.

When we create a website, we now create one database in the database, one for each database.Creating this library means that the next data we have to store in this library, which is like having a storage cabinet ready in advance.


 Methods of creating Libraries 
create database < Database Name >;

 View Library  
show databases;

 Select Library  
use < Database Name >;

Having multiple libraries in a database often means that the database holds data from multiple websites.

Once we have created a database, we can store things in it.

Storage is also categorized, such as a shopping mall, user data and commodity data, although all of them are data from this database, it would be confusing if not divided.At this point we need to create a table to categorize and assign each type of data to each table.

For example, in a shop website, user information will add a table, and when a user registers or modifies data, it will write data to the table.When adding goods, add data to the list of goods;When there is a comment on a commodity, there will be one more piece of data for the corresponding comment table.So when we want what kind of data we want, we pick it directly from this table.


 Create Table 
create table msg (
id int primary key auto_increment,
name char(20),
email char(30),
content varchar(100)
) charset utf8;

 View the table under the library  
show tables;

 Lookup table  
select * from msg;

Once the database and tables are available, we can add and modify data content for the database through logical judgment and other methods.

Thank you for reading, I hope to help you, thank you for your support on this site!


Related articles: