MySQL Learning _20160919

Source: Internet
Author: User

1. First look at what is MySQL.

MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently part of Oracle's product portfolio. MySQL Most popular relational database management system, its open source This feature, makes the general small and medium-sized website development all chooses MySQL as the website database.

2, installation.

Installation reference: http://jingyan.baidu.com/article/90bc8fc8615c99f653640cc4.html

You can download the installer from the MySQL website and run Mysql-installer-community-5.7.10.0.msi Select the installation path.

  Create a Local Service login name and password during installation The next step is to use

  

3. Installation Management tool-SQLYOG connection management MySQL Database

  

4. SQL statements

Learn how to get started with the http://www.w3school.com.cn/sql/index.asp

#4.1 creating databases, database tables

#一 Create/delete database and data tables and insert records to delete records #创建数据库 CREATE DATABASE test# Delete drop database test# creating, deleting data tables (deleting creates to drop) CREATE TABLE test _A (User ID varchar (255), Salesperson varchar (255), KEY res_id (User ID)) ENGINE INNODB DEFAULT Charset=utf8 #engine indicates that the database engine is INNODB # CH Arset=utf8 indicates that the database encoding is UTF8 encoded # Modify table name alter tables table name rename new table name ALTER TABLE test_a rename test_a001; #把test_a表修改为 test_a001# Delete Table Dro P table test_a001# determine if the database table exists decide to create or delete # If there is a exists database test_a delete the drop db if exists test_a #如果不存在数据库test_a creates a create DA Tabase if not EXISTS test_a# if there is a data table test_a delete the drop table if EXISTS test_a #如果不存在数据表test_a creates a CREATE table if not EXISTS te St_a#3 insert a record without select Update a value delete insert INTO A003_order (user ID, amount, Order date) VALUES (790000000,null, "2013-01-02 00:01:02"); The update amount null value should be 0UPDATE a003_order SET amount =0 where user id=790000000 #查询是否更新 originally null value should now be 0SELECT User ID, amount, order date from A003_order where id=790000000; #再插入一条记录 See ifnull function effect INSERT into a003_order (user ID, amount, Order date) VALUES (790000000,null, "2013-01-02 00:01:02") ; #4 ifnull (null value null,0) null value replaced by 0 for selectId,sum (IF (Order date > "2013-01-01", Amount, NULL)) as Amount 1,ifnull (sum (amount), 0) as amount from A003_order as Awhere user id=790000000# 5 Delete data table record Delete from A003_order where user id=790000000# query is deleted should be all empty Select User ID, amount, order date from A003_order where user id=790000000 0;

#4.2 SQL Execution Order

(8) Select (9) distinct (one) top 1 (6)  Table1.id,count (Table1.name) as Namecount (1) from Table1 (3) INNER JOIN Ta Ble2 (2) on table1.id=table2.id (4) where TABLE1.ID<4 (5) Group by Table1.id (7) has table1.id<3 (ten) Order by Tab Le1.id desc

  

MySQL Learning _20160919

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.