Details of the process for Mysql to create a datasheet
This article mainly introduces the details of the data table creation process of Mysql. I hope I can supplement and update some knowledge for you. If you have any other questions you need to know, you can continue to follow my updated article in the industry information. The data table is one of the most important parts of the database and the basis of other objects. If our database does not have data tables, there is no real place to store data (recommended course: MySQL tutorial)
Open the database
We log in to mysql and open the database we want to open.
USE keyword
We open the database named test and command:
USE test
After opening the database, let's create a data table. let's take a look at the command rules for creating a data table.
CREATE TABLE [IF NOT EXISTS] table_name (column_name data_type, column_name data_type,...)
Parameter description
The name of the column_ name column data_type data type
Let's create a basic data table, user name, age, password, salary.
CREATE TABLE ta1 (usename VARCHAR (20), age TINYINT UNSIGNED, passwrod VARCHAR (16), gz FLOAT (8) UNSIGNED)
For the above command, we declare a data table as ta1. The data table has four fields.
A user name with a usename field of 1 to 20 characters
The age field is a number of 0255and UNSIGINED is represented as an unsigned type
Passwords with 1 to 16 characters in the passwrod field
The gz field is 8 digits, 2 decimal places, and UNSIGINED is represented as an unsigned type
After we have created the data table, let's check to see if it has been created successfully.
Command rule
SHOW TABLES [FROM ab_name] [LINK 'pattern' | WHERE expr]
Enter the command to view the datasheet:
SHOW TABLES
After looking at the data table, let's check to see if the data structure of the data table is the same as the one we created.
View the command rules for the data structure:
SHOW COLUMNS FROM table_Name
Enter commands to view the data structure
SHOW COLUMNS FROM user
We can see that the data structure is exactly the same as it was specified when it was created.
These are the details of the data table creation process of Mysql. Please pay attention to other related articles for more information.