This paper deals with MySQL The basic knowledge of database is summarized and combed , The main contents are knowledge database 、 Common database rankings 、SQL And DDL Operating the database . I hope that after you read it , Be able to understand the concept of database , And be able to use SQL Statement operation database .
1、 Know the database
(1) How data is stored
a. Memory : Fast , But it can't be preserved forever , Data is temporary state .
b. file : Data can be stored permanently , But it's not convenient to manipulate the data , You need to query some data .
c. database : Data can be stored permanently , Fast query speed , The management of data is convenient , But it takes up resources , Need to buy .
(2) The concept of databases
A database is a warehouse for storing data , It's essentially a file system , Or in the form of files on the server computer . And all relational databases can use common SQL Statement Management .
2、 Common database rankings
a.MySQL: Open source free database , Small database , Has been Oracle Acquired .MySQL6.x The version also began to charge . later Sun The company acquired MySQL, and Sun The company was again Oracle Acquisition .
b.Oracle: A large database of charges ,Oracle Products of the company .
c.DB2:IBM The company's database products , Rechargeable . Often used in banking systems .
d.SQL Server:MicroSoft A database of medium-sized companies that charge .C#、.net Such language is often used .
e.SQLite: Embedded small database , It's used on the mobile phone , Such as :Android.
3、SQL The concept of
SQL(Structured Query Language) Chinese is also called structured query language . It is a query specification for all relational databases , Different databases support . As a general database operating language , It can be used in different databases . Different databases SQL There are some differences in sentences .
4、DDL Operating the database
(1) Create database
a. Create database directly db1
create database db1;
b. Judge whether it exists , If it doesn't exist, create the database db2
create database if not exists db2;
c. Create a database and specify the character set as gbk
create database db3 default character set gbk;
(2) view the database
Press tab Key can automatically complete the keyword
—— View all databases
show databases;
—— View the definition information of a database
show create database db3;
show create database db1;
(3) modify the database
Modify the default character set of the database
ALTER DATABASE Database name DEFAULT CHARACTER SET Character set ;
Specific operation :
take db3 The character set of the database is changed to utf8
alter database db3 character set utf8;
(4) Delete database
Delete database Syntax
DROP DATABASE Database name ;
Specific operation :
Each row SQL Statement needs to be selected for execution , Can press F9
Delete db2 database
drop database db2;
(5) Using a database
View the database in use
SELECT DATABASE(); One used mysql Global functions in
Use / Switch database
USE Database name ;
Specific operation :
—— View the database in use
select database();
—— Change the database to be used
use db4;
That's all MySQL Summarize and sort out the basic knowledge of database , Does everybody understand ? Zhengzhou men's gynecology hospital ranking list :http://news.39.net/ylzx/zztjyy/ Zhengzhou infertility hospital :http://yyk.39.net/zz3/zonghe/fc964.html