And the basic operation of the database storage engines mysql mysql database storage engines and the basic operations of

First, the stock of knowledge

Database server: A computer (higher memory requirements)

Database management systems: such as mysql, is a software

Database: oldboy_stu, the equivalent of a folder

Table: student, scholl, class_list, equivalent to a specific file

Record: 1 susan 158426544 22, corresponds to the line in the file content

Second, the initial SQL language

SQL (Structured Query Language that is Structured Query Language)
SQL language mainly used for data access, query data, update data and relational database management system, SQL language developed by IBM. SQL language is divided into three types:
DDL statements database definition language: databases, tables, views, indexes, stored procedures, such as the ALTER DROP the CREATE
DML database manipulation language statement: insert data INSERT, delete data DELETE, update data UPDATE, SELECT query data
DCL statement database control language: for example, control user access rights GRANT, REVOKE

Third, the system database

SQL (Structured Query Language that is Structured Query Language)
SQL language mainly used for data access, query data, update data and relational database management system, SQL language developed by IBM. SQL language is divided into three types:
DDL statements database definition language: databases, tables, views, indexes, stored procedures, such as the ALTER DROP the CREATE
DML database manipulation language statement: insert data INSERT, delete data DELETE, update data UPDATE, SELECT query data
DCL statement database control language: for example, control user access rights GRANT, REVOKE

Fourth, create a database

Database naming rules:

May consist of letters, numbers, underscore, @, #, $ 
case sensitive 
uniqueness 
can not be used as create select keywords 
can not be used alone digital 
longest 128
create database db1

Fifth, the database-related operations

Copy the code
Related to the operation of the database 
Note: The database is equivalent to the folder 
      list is equivalent to the file 
naming database: a database of additions and deletions to change search (sql statement). 
Add: create database db1; 
deleted: drop database db1; 
change: alter database db1 charset utf8 
search: Show databases; 
# View all databases 
    show create database db1; check the specified database 
set the default utf8, in the configuration file: write character_set_server = utf8 
use the DB2    # represent you double click Change directory 
the SELECT database () # View your current which folder 
two additions and deletions to change search table. 
add: create table t1 (id int, name char); (t1.frm table structure, t1.ibd table data) 
deleted: drop table t1; 
changes: 
insert data : INSERT INTO Test (ID, name) values ( . 1, ' X ' )
To whom does the designation by value are passed, but also by location Chuan 

check: Show the Tables;   # view all tables 
   Show the Create the Table T1; # View the table specified 
   the SELECT * from T1 # view table data 
   the SELECT the above mentioned id, name from T1   # View table data 
engine = InnoDB 
tables InnoDB storage engine
Copy the code

 

Sixth, what is the storage engine?

Storage engine that white is how to store data, how to index data stored and how to update, query data and other technologies to achieve square
method. Because the data stored in the relational database is stored in a table, the storage engine can also be referred to as a table type (i.e., type of operation and store this table)

SQL parser, SQL optimizer, pool, storage engines and other components are present in every database, but not so much for each database storage engine. MySQL's pluggable storage engine that allows developers to design their storage engine layer of the desired storage layer, for example, some applications need to meet the requirements of affairs, some applications do not need to have a very strong demand for the transaction; some want the data lasting memory, some just want to fit in memory, and temporarily provide access to data quickly. 

One type of show is a storage
storage engine: is the type of table, will correspond to different types of different mechanisms to handle his
affairs: that is, at the same time either succeed or not succeed at the same time

Use storage engine

Method 1: The construction of the table specified

Storage Engine
 1.Create Table T1 (ID int) = Engine innodb occur two files
 2.create Table T2 (ID int) = Engine MyISAM appears three files (faster than the above), but we use stored innodb 
 the table T3 3.Create (the above mentioned id int) Engine = memory not only table data table structure is created in memory of
 4.create table t4 (id int) engine = blackhole black holes, eating data (data stored inside, there is no, keep inside, there is no)

Method 2: Specify the default storage engine in the configuration file

/etc/my.cnf
[mysqld]
default-storage-engine=INNODB
innodb_file_per_table=1

 

First, the stock of knowledge

Database server: A computer (higher memory requirements)

Database management systems: such as mysql, is a software

Database: oldboy_stu, the equivalent of a folder

Table: student, scholl, class_list, equivalent to a specific file

Record: 1 susan 158426544 22, corresponds to the line in the file content

Second, the initial SQL language

SQL (Structured Query Language that is Structured Query Language)
SQL language mainly used for data access, query data, update data and relational database management system, SQL language developed by IBM. SQL language is divided into three types:
DDL statements database definition language: databases, tables, views, indexes, stored procedures, such as the ALTER DROP the CREATE
DML database manipulation language statement: insert data INSERT, delete data DELETE, update data UPDATE, SELECT query data
DCL statement database control language: for example, control user access rights GRANT, REVOKE

Third, the system database

SQL (Structured Query Language that is Structured Query Language)
SQL language mainly used for data access, query data, update data and relational database management system, SQL language developed by IBM. SQL language is divided into three types:
DDL statements database definition language: databases, tables, views, indexes, stored procedures, such as the ALTER DROP the CREATE
DML database manipulation language statement: insert data INSERT, delete data DELETE, update data UPDATE, SELECT query data
DCL statement database control language: for example, control user access rights GRANT, REVOKE

Fourth, create a database

Database naming rules:

May consist of letters, numbers, underscore, @, #, $ 
case sensitive 
uniqueness 
can not be used as create select keywords 
can not be used alone digital 
longest 128
create database db1

Fifth, the database-related operations

Copy the code
数据库的相关操作
注意:数据库就相当于文件夹
      表就相当于文件
数据库的命名规则:
一.数据库的增删改查(sql语句)
增:create database db1;
删:drop database db1;
改:alter database db1 charset utf8
查:show databases;#查看所有的数据库
    show create database db1;查看指定的数据库
设置默认的utf8,在配置文件中:写上character_set_server = utf8
use db2   #代表你鼠标双击切换目录
select database() #查看你当前在哪个文件夹
二.表的增删改查
增:create table  t1(id int ,name char);  (t1.frm 表结构  ,t1.ibd 表数据) 
删:drop table t1;
改:
插入数据:insert into test(id,name) values(1,'x')
不写给谁传值就指定都传,而且还是按照位置传

查:show tables;  #查看所有表
   show create table t1;#查看指定的表
   select * from t1 #查看表数据
   select id,name from t1  #查看表数据
engine = InnoDB
表的存储引擎是InnoDB
Copy the code

 

六、什么是存储引擎?

存储引擎说白了就是如何存储数据、如何为存储的数据建立索引和如何更新、查询数据等技术的实现方
法。因为在关系数据库中数据的存储是以表的形式存储的,所以存储引擎也可以称为表类型(即存储和操作此表的类型)

SQL 解析器、SQL 优化器、缓冲池、存储引擎等组件在每个数据库中都存在,但不是每 个数据库都有这么多存储引擎。MySQL 的插件式存储引擎可以让存储引擎层的开发人员设 计他们希望的存储层,例如,有的应用需要满足事务的要求,有的应用则不需要对事务有这 么强的要求 ;有的希望数据能持久存储,有的只希望放在内存中,临时并快速地提供对数据 的查询。 

一种类型表明的是一种存储方式
存储引擎:就是表的类型,不同的类型就会对应不同的处理机制去处理他
事务:就是要么同时成功,要么同时不成功

使用存储引擎

方法1:建表时指定

Storage Engine
 1.Create Table T1 (ID int) = Engine innodb occur two files
 2.create Table T2 (ID int) = Engine MyISAM appears three files (faster than the above), but we use stored innodb 
 the table T3 3.Create (the above mentioned id int) Engine = memory not only table data table structure is created in memory of
 4.create table t4 (id int) engine = blackhole black holes, eating data (data stored inside, there is no, keep inside, there is no)

Method 2: Specify the default storage engine in the configuration file

/etc/my.cnf
[mysqld]
default-storage-engine=INNODB
innodb_file_per_table=1

 

Guess you like

Origin www.cnblogs.com/maaosheng/p/11619388.html