MySQL Learning Tutorial - 1. Overview

1. Overview of MySQL

 

1. MySQL architecture
C/S: client / server architecture
MySQL DBMS(Data Bank Management System): database management system
client <---> server---> database---> data table---> (record/ row, field/column)

2. Operations that need to be mastered during development:

1. Design a table for the project
2. Use SQL statements (SQL statement programming)
to operate MySQL client tools including dbvisualizer, navicat, and SQLyog.
3. MySQL file structure
  configuration file: my.ini: You can configure the corresponding attributes of MySQL by modifying this file.
Bin file directory: Save all MySQL command
data file directory: Save the libraries included in MySQL, each library contains It is the corresponding table
(when backing up, just pack the data folder and back it up, it is var under Linux)
4. SQL statement operation
SQL (Structured Query Language) is an advanced non-procedural language.
SQL statement: simple structure, powerful function, easy to learn!
Divided by function:
DDL: statement for creating database and data table
DML: statement for operating data
DQL: database query statement
DCL: statement for data control, which can be executed by tools.
For example: \s View status
show databases; View all databases
show tables; View all tables
desc tables; View table structure
show variables; View variables in the configuration file


DDL: (Data Definition Language)

1. To execute an SQL statement, first connect to the database server:
mysql -h localhost -u root -p #Log in to the local database as the root user
\s: View the database status
show variables;: View the variables configured by default in the system, please Note: end with;
show variables like 'time_zone';
show variables like 'port'; : view ports
show databases; : show all the libraries in the system
2. Create database
create database [name];
such as: create database boost;
3. Delete database
drop database [name];
such as: drop datebase boost;
  extension: cteate database if not exists boost;
drop database if exists boost;
4. Create a data table
create table boost.users(id int,name char(30) ,age int,sex char(3));
5. Select a library as the default database
use boost;
6. View all tables
show tables;
7. View table structure
desc users;
8. Delete table
drop table users; // drop table if exists users;
9. Continue to create
create table users in the default database (id int,name char(32),age int,sex char(2));
Extension:
       create table is not exists users(id int,name char(32));
10. Create another table
create table is not exists articles(title char(64));


DML: (data manipulation language)

1. Insert data
insert into users values('2012','xiaofang','34','nan');
or: insert into users values(2012,'xiaofang',34,'man'); //weak type Check the
best practice: insert into users(id,name,age) values('2334','wangwu','56');
to insert partial or out of order.
2. Update data information
update users set name='AShun' where id='2012';
promotion: update users set name='XiaoChang', sex='female' where id='2012';
3. Delete data information
delete from users where id='2012';
promotion: delete from users // delete all

DQL:(Data Query Language

1. To view the data information, the query statement
select * from users;

 

http://blog.csdn.net/zjf280441589/article/details/18660397

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327073708&siteId=291194637