In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what are the basic operations of MySQL database and data table". In the daily operation, I believe that many people have doubts about the basic operation of MySQL database and data table. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "what are the basic operations of MySQL database and data table". Next, please follow the editor to study!
Preface
Naicat for Mysql usage
Usually, we connect to the mysql service through mysql.exe (client).
But there's a problem.
The first problem is that it is too ugly.
The second problem is because it doesn't prompt automatically. I've been accustomed to all kinds of automatic prompt tools. I'm using such Low.
Installation
The next step is the next step!
Crack
Administrator runs PatchNavicat
After opening it, navigate to the directory where Navicat for MySQL is installed and finish it.
New query
After connecting, click query, and then click New query, you can write SQL.
Some Conceptual understanding of Mysql
One concept that needs to be clarified first is that Mysql is not a database.
We are connecting to a Mysql service, not a database
So when someone hears about connecting to a database, it actually refers to the Mysql service that the connection runs.
Understanding of database
A database can be understood as a folder.
Use the show DATABASES; command to see which databases you have under you.
And then switch to
You can also find these folders.
If you data again, create a new folder.
Then through the show DATABASES; command to see which databases are currently available, you can find that there are indeed more folders (databases) that have just been created.
So we come to the conclusion that the database is actually a folder.
Understanding of data tables
The database is equivalent to a folder, and what is put in the database is the data table.
Table content
In fact, you will find that the datasheet is very similar to Excel.
Then Excel has whatever data sheet it has.
It is usually the table header (blue box) and the table content (red box).
Summary
A database is a folder.
Data tables cannot exist alone and need to be placed in the database. Xlsx is used as an example.
The database is divided into headers, table contents, rows and columns.
Database related commands
View the database under the current Mysql
Command
Show DATABASES
Result
Using the database
Using a database means.
The database is actually a folder, to use the database is to enter the database, which is equivalent to entering this folder.
Command
Use; # for example, use enters the database mysql
In daily use, if you want to operate the tables in which database, you must use this database.
Create a database
Command
CREATE DATABASE DEFAULT CHARSET utf8 COLLATE utf8_general_ci;# example to create a school database CREATE DATABASE school DEFAULT CHARSET utf8 COLLATE utf8_general_ci
Execution result
Delete database
DROP # example, delete school database DROP school
Datasheet related commands
Remember that you must use the database before you can manipulate the table.
Create a tabl
Format
Create table table name (column name column type [other parameters 1 other parameters 2.], column name column types [other parameters 1 other parameters 2...]) ENGINE=InnoDB DEFAULT CHARSET=utf8
Other parameters include
Whether it can be empty
Not null-- not nullable null-- nullable
Default value
Defalut 2-default 2
Self-increasing
Self-increment is generally used on id, and there can be only one self-increment column. You don't need to care about this column when you insert it, and you will automatically add values.
Auto_increment-- self-increment-- although it is fine to add this keyword since the primary key cannot be empty, it is necessary to cooperate with other keywords not null auto_increment primary key
Primary key
The primary key, a special unique index, does not allow null values.
If the primary key uses a single column, its value must be unique.
If it is multiple columns, the combination must be unique.
... Primary key (nid,num)
Foreign key
Constraint fk_cc foreign key (color_id) references color (nid)
Other parameters correspond to one by one.
Example
Create a master table
Create table teacher (id int not null auto_increment PRIMARY key, teacher_name varchar (16) not null) ENGINE=InnoDB DEFAULT CHARSET=utf8
Check which tables are in the database
Command
Show TABLES
Result
Delete tabl
Drop table
Clear the table
At this point in delete from truncate table, the study on "what are the basic operations of MySQL databases and data tables" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.