Database-Mysql, database mysql

Source: Internet
Author: User

Database-Mysql, database mysql

Let's talk about Mysql today. First, let's talk about itsHistory:

Mysql is a relational database management system. It was first developed by MySQL AB in Sweden and later acquired by sun. Later, sun was acquired by Oracle, as a result, MySQL is now a product of Oracle, and MySQL databases are now widely used in the industry.

Usage and case columns:

1) MySQL deployment structure

MySQL is deployed on the server and client software respectively. The server is responsible for data storage and maintenance, and the client is responsible for sending command requests to the server.

2) install and use the MySQL database

We recommend that you use xampp, which is a powerful website building integrated software package that can be installed and used in Windows, Linux, Solaris, Mac OS X, and other operating systems, it also supports multiple languages. It can be downloaded from Baidu. It is not very large. It is good to install it on drive C by default, and it does not occupy much space. Next, MySQL is used.

First, open xampp and enable the Mysql server. The default port is 3306,

The Red 1 arrow points out to open the server port, and then click the Red 2 arrow points out to open the client command line interface, here we generally open two, easy to run later.

After opening the page:

Input: mysql.exe-h127.0.0.1-P3306-uroot-p

Here, it can be abbreviated as mysql-uroot for direct access. Remember not to enter a semicolon at the end. Although you can also enter it, the identity you enter will change to the guest identity rather than the super administrator identity.

The following describes some common MySQL management commands:

Quit; quit

Show databases; displays all databases on the server

Use + database name; enter the specified database

Show + tables; displays all tables of the current database

Desc + Table Name; Description of the columns in the table (header)

You should note that these statements are followed by semicolons (in English.

Insert SQL syntax specifications:

A) each statement must end with A semicolon. A statement can be used across multiple lines. The semicolon indicates that the statement ends.

B) if the syntax of the nth statement is incorrect, the statement and all subsequent statements will not be executed.

C) SQL commands are case insensitive. Traditionally, all keywords in the database are in upper case, and all non-keywords are in lower case.

Next, let's talk about the commonly used SQL commands in Mysql (SQL: Structured Query Language, Structured Query Language, used to operate data in relational database servers). The SQL Language was first proposed by IBM, after submitted to ISO eventually became the database industry standard language, divided into multiple versions: SQL-87, SQL-92, SQL-99, etc., the current standard SQL commands can be supported by the vast majority of relational databases.

Two SQL statement execution methods:

1) Interaction Mode: enter a line on the client and click "enter". The server executes a line. This mode is suitable for temporary data viewing.

2) Script Mode: the client writes the multi-line command to be executed in a text file and submits it to the server for execution at a time. Applies to batch addition, deletion, modification, and query of data.

Submission method: mysql-uroot <path press enter (the path is too long to drag the file directly)

The following is the most common addition, deletion, modification, and query in SQL statements. For example: Create a class database with a student table, and a table with a header (sid SMALLINT, sname VARCHAR, sex CHAR, sage TINYINT, score FLOAT), insert several student records using SQL statements. Because there are a lot of statements to be written, here we use both SQL Execution Methods, first create a demo anywhere on the computer. SQL (here you can create a text document and change its extension. SQL), it is worth noting that the path of this file must be an English path. do not contain Chinese characters or spaces. Otherwise, an error will occur. Drag it into EditPlus (a very useful Editor, which can be directly downloaded online, 2 MB), and then write the SQL script file,

After writing the code, open the command line (shell) window to execute the code. As mentioned before, you can open two commands at a time to facilitate execution,

No error is reported. Switch to the second window to start interactive mode.

Successful!

Here we will mention the commands we used earlier:

Mysql-uroot enters the client database as an administrator

Show databases; displays all databases on the current server

Use + database name; enter the database

Show tables; displays all tables in the current database

Select * from + Table name query records of all columns in this table

Next, let's modify the data in the table: Change the score of Li Ming in student to 480.

We can see that the change was successful.

Next, we will delete the record named Zhangqiang student.

We can see that the data is successfully deleted.

 

What I am talking about today is just a little bit of knowledge about Mysql and some basic operations. I will continue to update it in the future. I hope it will be useful to you.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.