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)