Database MySQL Learning notes (i)

Source: Internet
Author: User

Mysql database is the best choice for beginners of database, its syntax is simple, the use of non-underlying SQL language definition (DDL), Operation (DML), control (DCL) database.

Getting Started: Servers, libraries, tables.

(1) Install MySQL server, configuration file, data and path.  Mysqld.exe is the server side, then installs the customer service side which satisfies the server-side communication specification (customer service side is not unique) such as different browser, command line-based Mysql black window, Mysql_fornt,navcat, Web-based phpMyAdmin. (Beginners are advised to use the command line-based MySQL black window to familiarize yourself with the CMD environment in Windows)

(2) Connect to the server, using the MySQL address username password, such as Mysql-host (-h) Localhost-u Root-p Enter the password or mysql-u root-p enter the password.

(3) Enter the view library, show databases; The MySQL database has four library Information_schma (about basic information), MySQL (about users), Performance_schma (about optimization information), and these three libraries are system libraries. Another library test is a library that can be directly manipulated,

The delete,update,modify,select of the future are all on test.

(4) Getting Started statement: Show databases;--View all databases Create database php;--creates a db named PHP use php--PHP Library, the name of the library cannot be modified, but the name of the table can be modified

CREATE table score;--creates tables rename table score to new score;--renaming tables--delete tables/libraries in two ways Dorp delete such as Dorp datebase Test show T ables;--Displays all table names description or DESC table class;--Displays the contents of the table.

CREATE TABLE MSG (

ID int,

Title varchar (20),

Name varchar (20),

Content varchar (1000)

);--Making a class table, building a table is just a process of declaring a column

(5) To increase the deletion of four basic statements: first consider the character set incompatibility problem: The default build table is generally used UTF8, but our command-line window under window is GBK, so we need to declare the character set:

Set names GBK; (otherwise the Black window will error 1366)

#往msg表中增加一行数据 (Increase)

INSERT into MSG (id,title,name,content)

VALUES (1, ' Zhang San ', ' newcomers ', ' Can you be the boss? ‘);

Select *from msg;--list msg all columns (query)

INSERT into MSG (id,title,name,content)

VALUES (1, ' John Doe ', ' Come Again ', ' You can only be thousand-year-old ');--John Doe's label ID is wrong to modify

#修改: Update msg

Set id=2,content= ' to be the eldest ' where Name= ' John Doe ';--where conditions explain which line to modify

Select *from msg;--Query new table display by column

INSERT into MSG (id,title,name,content)

VALUES (3, ' 3 titles, ' Liu Bei ', ' male and female swords '),

VALUES (4, ' 3 titles ', ' Guan Yu ', ' Tsing Lung Yan Yue Dao '),

VALUES (5, ' 5 titles ', ' Zhang Fei ', ' Zhang Eight Snake Spears ');

Select *from msg;--Query new table display by column

#删除 (delete by row, location with condition where)

Delete from msg where id=2;--deletes the second row

#查询 Select Id,title from msg;--query only id,title two columns

Select *from msg where id>2;--only view Liu, Guan, Zhang all columns

Select Name,content from msg where id>2;--only view Liu, Guan, Zhang's name and weapon

Database MySQL Learning notes (i)

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.