Learn to have small -mysql database -01

Introduction to database

1concept

()

2History of database development

 

refers to the storage and management of data based on the network model that records the type of nodes.

 

 

 

 

 

 

To organize and manage data databases.

 

The relational model is

),DB2(IBM)

 

Microsoft Corp),MySQL()

 

Microsoft Corp)

 

noSQL

 

MangoDB,Redis

5sqlbrief introduction

 

Structure  Query  Language

can be passed.Window

2Login to MySQL database server

” document, the operating environment iscmd

mysql  -h > port number-u-p password

explains:

-h mysql” means the machine.  127.0.0.1” means the machine. If it is the machine, it can be omitted.

-P default, it can be omitted.

-u >root password ” is not recommended.-p()

3mysqlHierarchical structure

DBMS DataBase Management System

Table corresponds to the form in reality.)

Record

Three basic operation of database

 1view the database

Grammar:

show databases;

explains:

testMySQL2 creating database in song style

 

  explains:

(“) > is used to set the stored character set.

collate

>:

> ended. The role of semicolons and cars is to connect customers.cmd

show create database explains:

4Delete database

 ;

5Select database

 ;

explains:

database, it is necessary to enter the specified database first.

 

> can view database information, which contains the database information currently in existence.

Four basic operation of data tables

1Set up the client’s communication code.

> client

explains:

What is the code for the current client to communicate with the server?

2View data tables

explains:

3Create data tables

(

> Field  > Table option.

explains:

 

The data type in the corresponding program

 

【Table options]

 

charset >

 

engine storage engine

 

( heading)

 

4View table structure

;

5View the creation statement of the table

;

6Delete table

;

Five basic operation of data

1Add data

()values()

 

explains:

 

value list of the song body must be quoted.

 

> fields can also be omitted, if omission indicates that all fields are inserted into the data. The order of the value list is consistent with the order of the fields in the table.

 

2View the data

 

①、 > Fields from where clause”.group by clause”.having clause”.order by clause”.limit explains:

  *    All fields

is used to view some fields.

 

Examples:

②、where

wherewhere” clause in the song style is used to screen the records. That is, the expression will involve the operator.

MySQL,<,>=,<=,<>,=,and,or,not,between m and n,in(),is null,like

= ” is used to judge whether it is unequal or assignment operator.

and,or Logic and logic or

between m and n n > value list) is only for judgement.null > placeholder:%,_

% represents the current position and its post.0 or more characters.

_

 

 

:between m and n

3Modifying the data

 set , ,…  where

where indicates that all records match.

4Delete data

 where explains:

where

> view data:select >

 

 1Numeric type

①、Integer type

The integer type is a series, all integers, the only difference is that the number can be represented by the same size.

②、 decimal type

):

double

Grammar:

float(m,d)

double(m,d)

explains:

m represents the total number.

d represents the decimal place.

m-d

explains:

float5 to the song body.60 replace

double14 to the song body.15 replace

decimal( fixed-point type):

explains:

m ” represents the total number.,m65

d represents the decimal place.,d

2Character

①、Fixed length

represents the number of characters. The biggest is255“.

②、Change length

represents the number of characters.The theory is 65535.” will be subject to many conditions.)

Examples:

③、Text type

text is also a series, including

tinytext,text,mediumtext,longtext④、blob type

blob > is also a series, including

tinyblob,blob,mediumblob,longblob“?

blog⑤、Enumerated type

” is used to standardize data, and only allows users to select one from a number of predetermined data.

Grammar:
enum()

⑥、Set type

” is used to standardize data, allowing users to select more than one predetermined number of data.

Grammar:
set()

Examples:

3 date time type

year(2 or4) 2;44

date format: ‘2017-12-4’

time format: ’17:14:59′

datetime date time type

Seven character set and proofreading set

1character set

①、SeeMySQL

 

 

2Validation set

A checkset is a comparison rule in a set of characters. That is, case sensitive.

show collation;

Tips:

()

_ci CaseInsensitive > no case sensitive.)

_bin > case sensitive

verification set is mainly reflected in comparison.

 

Leave a Reply

Your email address will not be published. Required fields are marked *