MySQL学习笔记(四)
一、存储引擎
# 查看所支持的引擎
show engines;
# 查看数据库默认使用的引擎
show variables like '%storage_engine%';
查看存储引擎
create table test(
`id` int primary key auto_increment,
`name` varchar(50)
)engine=InnoDB;
# 查看所有表当前使用的存储引擎
select * from information_schema.tables;
# 等价于
use information_schema;
select * from tables;
# 查看某个表当前使用的存储引擎
select * from information_schema.tables where Table_Name='test';
# 只查看engine 属性
select `engine` from information_schema.tables where Table_Name='test';
# 指定数据库的数据表(防止不同数据库重名的数据表)
select * from information_schema.tables where Table_Schema='info' and Table_Name='test';
修改表的存储引擎
# 修改表的存储引擎
alter table `test` engine=MyISAM
select * from information_schema.tables where Table_Schema='info' and Table_Name='test';
二、插入数据(DML)
单条
多条
语法:
insert into 表名(字段1,字段2,…,字段n)
values (值1,值2,…,值n),
(值1,值2,…,值n),
…;
提取某几列保存到新的表
语法:
create table 新表名(
select 列1 [as 新列名1],列2 [as 新列名2],…,列n [as 新列名n] from 旧表名
);
# 创建新表单独保存学生地址
create table if not exists