In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
In order to learn to build servers and databases, so recently began to self-study the sql language, as for writing the database to use the more basic Mysql database, although Mysql has been eliminated by Internet companies, they are using sql languages such as Nosql,SQL server, and finally decided to start from the basics. After a simple decision, I wrote it with the extremely high cmd command line. Mysql database installation method is not given here detailed tutorials, there are many online installation tutorials can choose to install.
1. The first step is to build a library in Mysql
Take Mysql5.0 as an example, log in to Mysql from the command line after installation:
On the command line, enter: mysql-u root (user name)-p
Then log in to the database after entering the password as prompted
After logging in, enter show databases to see which libraries are in the database:
One of these is:
Information_schema
Mysql
Test
Performation_schema
These three libraries are shipped with mysql after installation. You don't have to use them to ok. Next, create your own database to use:
Enter create database Cheung, then use the database you created, and enter use Cheung
The appearance of the above interface indicates that the database we are currently using is Cheung, so we are ready to ok. Let's start the formal practice of the sql statement.
two。 Let's learn how to create a table:
Enter the following operation on the command line to create a table in the database. You can see that some operations will put single quotation marks on the name of each data, which can be avoided, and the effect of the two is the same:
This means that the table tab to be used has been created, and we can type: desc tab
To see if the table you see is correct
Note that the input of each data should be separated by a comma, otherwise there will be a table error ERROR, this time is generally very embarrassing, so we must pay more attention to the details, do not add more parentheses between the last parenthesis and the data, because add it and there will be errors.
3. Update the structure of tables in the database
Update the definition of the table by adding a command to the table using the alter table + table name:
If you want to delete a column from the table, you will need to use the keyword Column, as follows:
If you want to delete the entire table, just type:
4. Insert data using Insert
Let's take a look at the structure of the tab table now:
To insert data into the table, use the insert statement in the format:
Insert into table name (column name 1, column name 2,...) Values (value 1, value 2,...)
Insert a complete set of data below:
Note that I did not set the value of id in advance to increase itself, that is, it was not written down when creating the table:
Id int not null auto_increment
Therefore, the id column in the table cannot be self-added, so you need to write the id item when inserting data, otherwise an error will be reported.
Then all you need to do is insert multiple sets of data into the created table at the same time:
When I wrote these operations for the first time, they all went through a lot of hard work, and finally I was able to live up to my efforts, and I finally knocked out the correct answer at 3: 00 in the middle of the night.
It is relatively easy to query the data in the table, so I won't say much about it here.
5. Update a column using the update statement
The format is: update table name set attribute 1 = new value 1, attribute 2 = new value 2 where attribute 3 =?
The format is not difficult to understand, the key is to use it skillfully.
Finally, delete the table data:
And finally empty the entire table:
Such a complete Mysql command line high pressure grid operation is completed, I have not come into contact with a similar database language in the process of directly using the command line, in the process of stepping on a lot of holes, here also help you mine clearance, in the future, if there is a similar problem is also easy to solve, will continue to learn other SQL language.
The above is the detailed explanation and integration of the Mysql command line operation introduced by the editor to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!
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.