当前位置:网站首页>That's great. MySQL's summary is too comprehensive

That's great. MySQL's summary is too comprehensive

2022-06-21 06:20:00 Stair hopping Penguin

Preface

 Please add a picture description

&#x1F680 One 、MySql database

 Please add a picture description

Every time I go to school, I only need to take the course of database , Too sleepy , Only later did we realize the importance of databases .

For me now , Let me learn about databases , Enthusiasm and interest are growing , Hence the article .

&#x1F344 1. Introduce

MySQL It's a real multiuser 、 Multithreading SQL database server .SQL( Structured query language ) Is the most popular and standardized database language in the world , It makes storage 、 It's easier to update and access information .MySQL It's a client / The realization of server structure , It's made up of a server daemon mysqld And many different client programs and libraries .MySQL The main goal of is to 、 Robust and easy to use . At first, it was because MySQL The founder of needs such a SQL The server , It can handle large databases in an order of magnitude with any manufacturer that provides databases on any inexpensive hardware platform , But faster ,MySQL So it was developed . It provides C,C++,Java(JDBC),Perl,Python,PHP and TCL Of API Interface ; Multi platform support , Include Solaris,SunOS,BSDI,SGI IRIX,AIX,DECUNIX,Linux,FreeBSD,SCO OpenServer,NetBSD,OpenBSD,HPUX,Win9x andNT; A variety of data types , It includes / Unsigned 1,2,3,4,8 byte integers,FLOAT,DOUBLE,CHAR,VARCHAR,TEXT,BLOB,DATE,DATETIME,YEAR,SET,ENUM; Very flexible and secure permission system , Password encryption ; by Windows Provide ODBC Interface , It can be done by Access Associated with it , Other third-party developers provide a variety of ODBC The driver ; stay MySQL 3.23 Using the new MyISAM The maximum table size can reach 8 One million TB(2^63 Bytes ); Multilingual support , But it doesn't support Chinese . However , In order to achieve fast 、 Purpose of robustness and ease of use ,MySQL Some flexible and powerful functions must be sacrificed , Such as sub query 、 Stored procedures and triggers 、 Foreign keys 、 Dealing with things, etc . thus ,MySQL Lack of flexibility in some applications , But this also makes its data processing speed at least faster than other database servers 2~3 times . > MySQL They don't support Windows Graphical interface of , therefore , All database operation and management functions can only be performed in MS-DOS To complete . First , Must log in MySQL The server , At the prompt /MySQL/BIN> The input MYSQL > –H host –U user –Ppassword, The prompt changes to mysql> When, it means that the login is successful . then , Select the database to operate , namely mysql> USEdatabasename. Then you can use SQL Statement . If you need to exit the database server , Executable QUIT command , In this way, you have successfully exited the server . Of course , because MySQL The popularity of , Many third-party software companies have launched MySQL stay Windows Support software with graphical interface in the environment , Such as EMS The company's EMS MYSQL MANAGER Provided. Windows Formal MySQL Database operation function . Posted on Xue163.com_MySQL

&#x1F345 2. advantage

MySQL The advantages of :

1. The core thread it uses is fully multithreaded , Support for multiprocessors . 2. There are several column types :1、2、3、4、 and 8 Byte length has its own sign / Unsigned integer 、FLOAT、DOUBLE、CHAR、VARCHAR、TEXT、BLOB、DATE、TIME、DATETIME、 TIMESTAMP、YEAR、 and ENUM type . 3. It's implemented through a highly optimized class library SQL Libraries and as fast as they can get , Generally, there should not be any memory allocation after query initialization . No memory holes . 4. Full support SQL Of GROUP BY and ORDER BY Clause , Support aggregate functions (COUNT()、COUNT(DISTINCT)、AVG()、STD()、SUM()、MAX() and MIN()). You can mix tables from different databases in the same query . 5. Support ANSI SQL Of LEFT 0UTER JOIN and ODBC. 6. All columns have default values . You can use it. INSERT Insert a subset of table columns , Columns that don't have a given value are set to their province values . 7. MySQL Can work on different platforms . Support C、C++、Java、Perl、PHP、Python and TCL API.

&#x1F346 3. shortcoming

MySQL The shortcomings of :

1、 MySQL The biggest drawback of the system is its security , It's mainly about complexity, not standards , In addition, only to call mysqladmin To reread user permissions . 2、 MySQL One of the other major drawbacks of the is the lack of standards RI(Referential Integrity-RI) Mechanism ;Rl The lack of restrictions ( A fixed range limit on a given field ) It can be compensated by a large number of data types . 3、 MySQL There is no stored procedure (Stored Procedure) Language , This is the biggest limitation for programmers accustomed to enterprise level databases . 4、 MySQL Hot backup is not supported . 5、 MySQL Prices vary with platform and installation .Linux Of MySQL If it is installed by the user or the system administrator instead of a third party, it is free , Third, we have to pay a license fee .Unix or Linux Its installation free 、Unix or Linux Third party installations require a fee .

&#x1F33D 4. Database comparison

Common databases are < Relational database system >: ORACLE( Oracle )、DB2、SQL
Server、Sybase、Informix、MySQL、VF、Access etc. .

&#x1F449 (1)、 performance

SQL Server The performance of the old version is poor when it is multi-user , The performance of the new version has been significantly improved , Each processing capacity has been significantly improved . A number of TPC-C Record . Specific see http://www.tpc.org/
Oracle The highest performance , keep Windows NT Under the TPC-D and TPC-C The world record for .
SYBASE Higher performance , Support Sun、IBM、HP、Compaq and Veritas Features of the cluster device , Achieve high availability . The performance is close to SQL Server, But in UNIX The concurrency under the platform should be better than SQL Server. Suitable for systems with high security requirements .
DB2 It is suitable for data warehouse and online transaction processing , Higher performance . Client support and application mode .
INFORMIX Higher performance , Support clusters , Achieve high availability . Suitable for systems with high security requirements , Especially banks , Application of securities system .

&#x1F463 (2)、 Scalability , Parallelism

SQL Server Previous version SQL Server Parallel implementation and coexistence models are not mature . Difficult to handle large numbers of users and data volumes . Limited scalability . The performance of the new version has been greatly improved , stay Microsoft Advanced Servers Have outstanding performance on , Surpassing his main competitor .
Oracle Parallel servers extend by making a group of nodes share work in the same cluster Window NT The ability of , Solutions to provide high availability and high scalability clusters . If Windows NT Can't meet the needs , Users can move the database to UNIX in , It has good scalability .Oracle Parallel server for a variety of UNIX The cluster mechanism of the platform has a high degree of integration .
SYBASE The new version has good parallelism , Fast , No significant impact on huge amount of data , But the technical implementation is complex , Need program support , Limited scalability . Although there are DB SWITCH To support its parallel servers , but DB SWITCH The technology is not mature yet , And only version is supported 12.5 The above ASE SERVER.DB SWITCH Technology requires a server to act as SWITCH, So it brings some trouble on the hardware .
DB2 DB2 It has good parallelism .DB2 Extended database management to parallel 、 Multi node environment . A database partition is part of a database , Include your own data 、 Indexes 、 The configuration file 、 And transaction logs . Database partitions are sometimes referred to as nodes or database nodes , Limited scalability .
INFORMIX Using single process multithreading technology , It has good parallelism . But only run on UNIX platform , Limited scalability .

&#x1F46A (3)、 Security

SQL server Microsoft Advanced Server Obtain the highest safety certification , The stability of the server platform is the foundation of the stability of the database , The new version of the SQL The security of has been greatly improved .
Oracle Server Get the highest level of certification ISO Standard certification .
SYBASE adopt Sun company J2EE Certification testing , Get the highest level of certification ISO Standard certification .
DB2 Get the highest level of certification ISO Standard certification .
INFORMIX Get the highest level of certification ISO Standard certification .

&#x1F4A2 (4)、 operation

SQL Server It's easy to operate , Using a graphical interface . Management is also very convenient , And the programming interface is especially friendly ( its SQL-DMO Make programming very convenient !) , In terms of maintainability and price SQL Server A clear advantage .
Oracle More complicated , At the same time provide GUI And the command line , stay Windows NT and Unix, Linux The next operation is the same . High requirements for database management personnel .
SYBASE complex , Use the command line , High requirements for database management personnel . At the same time provide GUI And the command line . but GUI Poor , It is often not in time , The command line is recommended .
DB2 It's easy to operate , At the same time provide GUI And the command line , stay Windows NT and Unix The next operation is the same .
INFORMIX Complex to use and manage , Command line operations . High requirements for database management personnel .

&#x1F554 (5)、 Use risk

SQL Server Completely rewritten code , Performance and compatibility have been greatly improved , And Oracle,DB2 The performance gap is significantly reduced . The product has been tested for a long time , It has conducted a comprehensive test for the safety and stability of the product , The safety and stability have been significantly improved . After a long test , Keep delaying , Many features take time to prove , It's not very compatible .
Oracle Long time development experience , Fully backward compatible , It's widely used , There is no risk at all . The database can be upgraded safely , In Enterprises 、 It is widely used in government . And if it's in WINNT Can't meet the data requirements , Can safely transfer data to UNIX come up .
SYBASE Backwards compatible , however ct-library The program is not easy to transplant . Long development time , The upgrade is complicated , Good stability , Data security is guaranteed . The risk is small . In banks with high security requirements , It has been widely used in the securities industry .
DB2 It is widely used in giant enterprises , Good downward compatibility . The risk is small .
INFORMIX Long development time , The upgrade is complicated , Good stability , Data security is guaranteed . The risk is small . In banks with high security requirements , It has been widely used in the securities industry .

&#x1F4A5 (6)、 open

SQL Server Only in Windows Up operation ,C/S structure , There's no openness at all , The stability of the operating system is very important to the database . Only support Windows Customer , It can be used ADO,DAO,OLEDB,ODBC Connect .Windows9X Series products are focused on desktop applications ,NT server Suitable for all kinds of large, medium and small enterprises . The stability of the operating system is very important to the database .Windows Platform reliability , Security has gone through the highest level of C2 The certification . It provides better performance when dealing with key businesses with large amount of data . and windows Platform reliability , Security and scalability are very limited . It's not like unix That's been tested , Especially in dealing with big databases .
Oracle Can run on all mainstream platforms ( Include Windows). Fully support all industrial standards . Adopt a completely open strategy . Multi level network computing , Support a variety of industrial standards , It can be used ODBC,JDBC,OCI Wait for network customers to connect . It enables customers to choose the most suitable solution . Full support for developers .
SYBASE Can run on all mainstream platforms ,C/S structure , It can be used ODBC、Jconnect、Ct-library Wait for network customers to connect . It has been widely used in the banking industry . But because of the early Sybase And OS The degree of integration is not high , therefore VERSION11.9.2 The following versions require more OS and DB Level patch . In a multi platform hybrid environment , There will be some problems .
DB2 Can run on all mainstream platforms ( Include windows). Good openness , Best for massive data . Cross platform , Multilayer structure , Support ODBC,JDBC Waiting for customers . It is widely used in large international enterprises , In the world 500 Of the largest companies , almost 85% Adopted above DB2 database server , And from home to 97 Annual share 5%.
IINFORMIX Only run on UNIX platform , Include SUNOS、HPUX、 ALFAOSF/1. It is widely used in banks .

&#x1F483 (7)、 Maintainability and price

SQL Server In terms of maintainability and price SQL Server A clear advantage . be based on Microsoft The consistent style of ,SQL Server The graphical management interface of brings obvious ease of use , Microsoft's database administrator training is quite adequate , You can easily find a good database administrator , The cost of database management is relatively low ,SQL Server The price is also very low , But in License Will raise the price on the purchase of . On the whole SQL Server Is the lowest price in a commercial database .
Oracle In terms of maintainability and price Oracle The price of is relatively high , Management is more complicated , because Oracle Is widely used , Experienced Oracle Database administrators can easily find , So as to achieve Oracle Good management of . therefore Oracle The performance price ratio of is the best in commercial databases .
SYBASE SYBASE The price of is relatively low , however SYBASE It has less application in enterprises and governments , It's hard to find experienced Administrators , High operation and management costs .
DB2 high price , Fewer Administrators , It is rarely used in China , The operation and management costs are very high , It is suitable for data warehouse applications in large enterprises .
INFORMIX Prices are in the middle of these systems , And SYBASE equally , It is less applied in enterprises and governments , It is only widely used in banks . Less experienced managers , High operation and management costs .

Source click here

&#x1F680 Two 、 command

&#x1F344 1. The command of

&#x1F449(1). Common database commands

command notes
show databases Query all libraries
show tables View all tables
create database name Create a new name name The library of
use name Use this library
drop database Delete database
create table Table name (1,2) Create a new table and add fields
dese Table name View the fields of all tables
show create database Library name Create a new library and view
show create table Table name Create a new table and view

&#x1F463(2). The command to modify the table

command notes
alter table Table name modify Field data type Change the data type of the field
alter table Table name add Field Add new fields
alter table Table name add Field 1 after Field 2 Add fields 1 The position of is in the field 2 after
alter table Table name drop Field Delete the fields under the specified table
alter table Table name change Field 1 Field 2 Change the field 2 Change the name of to field 1 The name of

&#x1F46A(3). Manipulation of data

&#x1F401 <1> Add data
insert into  Table name  values(1,2);  // Add data 1 And data 2
insert into  Table name ( Field 1, Field 2) values(1,2);// Add data 1 And data 2 To field 1 And field 2
insert into  Table name ( Field 1, Field 2) values(1,2),(3,4);// Multi data addition 
&#x1F403 <2> Delete data
delete from  Table name  where  Conditions ;
&#x1F405 <3> Update data
update  Table name  set  Field 1=1, Field 2=2 where  Conditions 
&#x1F407 <4> Query data
select* feom  Table name ; // Query all databases in the table 
select  Field  from  Table name ; // Query the fields under the table 
select  Field  from  Table name  where  Conditions ; // Query the fields according to the specified criteria ( Very often )
select  Field  from  Table name  id between 1 and 5;// The search field range is 1-5 The data of 
&#x1F409 <5> Sort the data
select  Field  from  Table name  order by  Field  (desc// Descending |asc// Ascending )
 for instance :
select* from studentname order by  name,studentid desc, age asc;// It is very simple to arrange the student numbers of the student list in descending order , Age in ascending order 
&#x1F40B <6> Data are grouped
 Grouping is simple group by  Just learn how to use it 
 Here is the main point :
select * from name limit( Offset , Number ); 
 among      Offset =(n-1) Number 

&#x1F4A2(4). Multi table joint query

The union here needs to talk about and or Usage of , Literally and That's right. or It's or

and:
select uname,id,passwd from root  and select whoani from admin;// This must be output at the same time 

or:
select uname,id,passwd from root  or select whoani from admin;// Select one output 

&#x1F554(5). Permission statement

control sentence
Create user create use
Authorized user grant all on Table name
Refresh user rights flush privilegs
Cancellation of authority revoke all on Table name
Delete user drop user

&#x1F345 2. Common functions

function meaning
version() Database version
database() Current database name
user() user name
sysem_user() System user name
current_user() Current user name
@@datadir Database path
@@version_compile_os Operating system version
length() Return string length
substr() Intercepting string
mid()left() Take characters from the left
cancat() No delimiter link string
concat_ws() Connection string with separator
group_concat() String connecting a group
ord() return ASCII Coding style
ascil() Convert to ASCII style
md5() return MD5( Irreversible encryption )
floor(x) Return is no greater than x Maximum integer for
round(x) Return parameters close to x The integer of
rand() return 0-1 Between random floating-point numbers
sleep() Sleep for a specified number of seconds
if(true,t,f)if Judgment statement

&#x1F680 3、 ... and 、 demonstration

&#x1F344 1. Basics

What I'm using here is nivacat The tools are mysql database , The following demonstrations are performed in this environment

&#x1F449(1) Building a database

&#x1F401 <1> open nivacat

 Insert picture description here #### &#x1F403 <2> Connect to database

Be careful. , Before using this software, you need to configure Mysql Database and any middleware , I use a small leather panel to build the environment

 Insert picture description here

&#x1F405 <3> Building database

Build a MySQL database

 Insert picture description here

Configure what you need , The password here is usually root perhaps 123456, If you don't know, you can view the configuration file

 Insert picture description here

When it's set up , Click these buttons to turn green, and the database will be set up successfully .

 Insert picture description here

&#x1F463(2) Query information

&#x1F401 <1> Query all database names

show databases;

 Insert picture description here

&#x1F403 <2> Query table

show tables;

 Insert picture description here

&#x1F405 <3> Query field

select id,pw from member

 Insert picture description here

&#x1F46A(3) Add data

insert into member(username,pw,sex,phonenum,address,email) values('admin','111','man','123','123','[email protected]');

 Insert picture description here

&#x1F401 <1> add table

 Insert picture description here

&#x1F403 <2> add table

 Insert picture description here

&#x1F4A2(4) Delete data

&#x1F401 <1> Delete Library

First look at the original table. There is a test Database
 Insert picture description here Execute delete command

drop database test;

We can see test Has been deleted

 Insert picture description here

&#x1F403 <2> Delete table

drop table jianyu;

 Insert picture description here

&#x1F405 <3> Delete field

delete from jianyu where shijian=2022;

 Insert picture description here

delete from member where id=25;

 Insert picture description here

&#x1F554(5) Change data

&#x1F403 <1> Change table

The original table is massage

 Insert picture description here

Input alter table message rename mg; // Modify the name of the table

 Insert picture description here

&#x1F405 <2> Change field

Original name=’ Jingle ‘ After modification name=‘ Zhang San ’

update message set name=' Zhang San ' where age=18;

 Insert picture description here

&#x1F680 Four 、 Summary

Here's a complaint : It's over ,1w2q word , Little penguins are too difficult .
 Insert picture description here

Personally, I feel that since the end of the database , The website data transmission also began to understand slowly , Learning needs not only depth but also breadth , Dear technical friends , Let's refuel together .

Dear friends, let's meet each other

 Insert picture description here

原网站

版权声明
本文为[Stair hopping Penguin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206210559026212.html